LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::arctanLUT Class Reference

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>

Inheritance diagram for lti::arctanLUT:
Inheritance graph
[legend]
Collaboration diagram for lti::arctanLUT:
Collaboration graph
[legend]

List of all members.

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 cfloatptratanLUT

Detailed Description

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)


Member Typedef Documentation

typedef const float* lti::arctanLUT::cfloatptr [protected]

Type required to create the LUT as a const structure.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Parameters:
dy y component must be between -255 and 255
dx x component must be between -255 and 255
Returns:
arctan(dy/dx) in radians (always possitive between 0 and 2*Pi)

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.

Parameters:
dy y component.
dx x component.
Returns:
arctan(dy/dx) in radians (always possitive between 0 and 2*Pi)

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.

Parameters:
dy y component.
dx x component.
Returns:
arctan(dy/dx) in radians (always possitive between 0 and 2*Pi)

References atanLUT, and lti::iround().

Referenced by operator()().


Member Data Documentation

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()().


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:28:09 2010 for LTI-Lib by Doxygen 1.6.1