TarzaNN
TarzaNN neural network simulator
|
Encapsulates relation between angles and "discretized" direction. More...
#include <Direction.h>
Public Member Functions | |
Direction (int resolution) | |
Resolution must be specified with the constructor. | |
~Direction () | |
int | getDiscrete (float ang_rad) |
Converts a real angle in radians to a discrete value. | |
float | getRadians (int discr) |
Converts a discrete angle to a real angle in radians. | |
const int | getResolution () |
Returns the current resolution. | |
const float | getIncrement () |
Returns the current increment between discrete angles in radians. | |
void | setResolution (int) |
Sets a new resolution for this object. | |
int | normDiscrete (int) |
Returns the normalized value of a discrete angle. | |
float | normRadians (float) |
Returns the normalized value of a real angle in radians. | |
const int | get90 () |
Returns 90 degrees as a discrete angle. | |
const int | get180 () |
Returns 180 degrees as a discrete angle. | |
float | sinD (int d) |
Returns the sine of a discrete angle. | |
float | cosD (int d) |
Returns the cosine of a discrete angle. | |
float | getSelectivity (int) |
Selectivity function - used in 7a layer (ART feature planes) |
Encapsulates relation between angles and "discretized" direction.
Since the model generally limits directions to be one of n discrete values, this class is used to provide a uniform interface to direction-based information for other parts of the code. These discrete angles are represented using integers in the range 0..n-1. A Direction object is initialized to a particular resolution. The resolution is equivalent to the number of discrete angles that will be generated. Discrete angles are evenly spaced around a single complete revolution, such that a discrete value of 0 always corresponds to "0 degrees" or "0 radians". Thus, if there are 8 discrete directions, then direction 0 is equivalent to "0 degrees", direction 1 is equivalent to "45 degrees", direction 2 is equivalent to "90 degrees" and so on.
Abstractions that this class provides includes conversion to and from real angles (specified in radians), the sine and cosine operations, normalizing values to be in the initial revolution (i.e. 0 to 360 degrees). An abstraction is provided for the co-efficient for the "selectivity" function that is used in layer 7a.
Resolution of Direction objects can be changed on the fly by calling the setResolution method. Typically the Direction object is managed by the MotionModel class.
Direction::Direction | ( | int | resolution | ) |
Resolution must be specified with the constructor.
Direction::~Direction | ( | ) |
float Direction::cosD | ( | int | d | ) |
Returns the cosine of a discrete angle.
const int Direction::get180 | ( | ) | [inline] |
Returns 180 degrees as a discrete angle.
Note that this function is only accurate if the resolution is divisible by 2.
const int Direction::get90 | ( | ) | [inline] |
Returns 90 degrees as a discrete angle.
Note that this function is only accurate if the resolution is divisible by 4.
int Direction::getDiscrete | ( | float | ang_rad | ) |
Converts a real angle in radians to a discrete value.
const float Direction::getIncrement | ( | ) | [inline] |
Returns the current increment between discrete angles in radians.
float Direction::getRadians | ( | int | discr | ) |
Converts a discrete angle to a real angle in radians.
const int Direction::getResolution | ( | ) | [inline] |
Returns the current resolution.
float Direction::getSelectivity | ( | int | k | ) |
Selectivity function - used in 7a layer (ART feature planes)
int Direction::normDiscrete | ( | int | discr | ) |
Returns the normalized value of a discrete angle.
float Direction::normRadians | ( | float | ang_rad | ) |
Returns the normalized value of a real angle in radians.
void Direction::setResolution | ( | int | r | ) |
Sets a new resolution for this object.
float Direction::sinD | ( | int | d | ) |
Returns the sine of a discrete angle.