latest version v1.9 - last update 10 Apr 2010 |
Following class provides a mono-state object that contains a 1MB Look-up Table to accelerate the computation of the arc-tangens. More...
#include <ltiArctanLUT.h>
Public Member Functions | |
arctanLUT () | |
float | operator() (const float dy, const float dx) const |
float | operator() (const double &dy, const double &dx) const |
float | operator() (const int dy, const int dx) const |
Protected Types | |
typedef const float * | cfloatptr |
Static Protected Member Functions | |
static void | constructArcTanLUT () |
Static Protected Attributes | |
static const cfloatptr * | atanLUT |
Following class provides a mono-state object that contains a 1MB Look-up Table to accelerate the computation of the arc-tangens.
The provided functionality is similar to std::atan2(y,x) which computes arctan(y/x) returning also the right angle quadrant.
This method is used in time critical operations. It is not appropriate if you need exact computations of the arctan. For that you can use the standard method std::atan2, which is of course much more time expensive.
As a mono-state class, only one instance of the LUT will be created.
To use it, just create an instance and use the operator() as if you were using std::atan2:
lti::arctanLUT myatan2; float angle = myatan2(20,10);
The returned angle will be always possitive 0 <= angle < 2*Pi (in radians)
typedef const float* lti::arctanLUT::cfloatptr [protected] |
Type required to create the LUT as a const structure.
lti::arctanLUT::arctanLUT | ( | ) |
Construct the class Here, the LUT will be build just once (if not already done).
The first time you construct this class, it will take about 0.15 seconds to build the LUT.
static void lti::arctanLUT::constructArcTanLUT | ( | ) | [static, protected] |
construct a atan2 LUT.
It will assume that the difference values of the gradients will be always between -255 and 255. The 1MB Memory required should not be a problem in modern PCs anymore!.
float lti::arctanLUT::operator() | ( | const int | dy, | |
const int | dx | |||
) | const [inline] |
Compute the arctan(dx/dy).
This is the fastest method, but the value range of the input variables is restricted.
dy | y component must be between -255 and 255 | |
dx | x component must be between -255 and 255 |
References atanLUT.
float lti::arctanLUT::operator() | ( | const double & | dy, | |
const double & | dx | |||
) | const [inline] |
Compute the arctan(dx/dy).
It is a little bit slower than the other atan2() method, as it needs to scale the input values into the range -255 and 255. If you need a extremely efficient computation, try the other atan2() method.
dy | y component. | |
dx | x component. |
References operator()().
float lti::arctanLUT::operator() | ( | const float | dy, | |
const float | dx | |||
) | const [inline] |
Compute the arctan(dx/dy).
It is a little bit slower than the other atan2() method, as it needs to scale the input values into the range -255 and 255. If you need a extremely efficient computation, try the other atan2() method.
dy | y component. | |
dx | x component. |
References atanLUT, and lti::iround().
Referenced by operator()().
const cfloatptr* lti::arctanLUT::atanLUT [static, protected] |
the arctanLUT with floats.
After calling constructArcTanLUT() the valid index range for both dimensions will be between -255 and 255. The arctanLUT[dy][dx] is equivalent to atan2(dy,dx) (but much faster). The entries will always be between 0 and 2*Pi.
Referenced by operator()().