last update 20 Sep 2009 |
#include <cvrArctanLUT.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 |
virtual const std::string & | name () const |
virtual arctanLUT * | clone () const |
virtual arctanLUT * | newInstance () const |
Protected Types | |
typedef const float * | cfloatptr_ |
Static Protected Member Functions | |
static void | constructArcTanLUT () |
Static Protected Attributes | |
static const cfloatptr_ * | atanLUT_ |
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:
cvr::arctanLUT myatan2; float angle = myatan2(20,10);
The returned angle will be always possitive 0 <= angle < 2*Pi (in radians)
typedef const float* cvr::arctanLUT::cfloatptr_ [protected] |
Type required to create the LUT as a const structure.
cvr::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.
virtual arctanLUT* cvr::arctanLUT::clone | ( | ) | const [virtual] |
static void cvr::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!.
virtual const std::string& cvr::arctanLUT::name | ( | ) | const [virtual] |
virtual arctanLUT* cvr::arctanLUT::newInstance | ( | ) | const [virtual] |
float cvr::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 cvr::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 cvr::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_, cvr::closeToZero(), and cvr::iround().
Referenced by operator()().
const cfloatptr_* cvr::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()().