CVR-Lib last update 20 Sep 2009

cvr::arctanLUT Class Reference
[Math]

Following class provides a mono-state object that contains a 1MB Look-up Table to accelerate the computation of the arc-tangens. More...

#include <cvrArctanLUT.h>

Inheritance diagram for cvr::arctanLUT:

Inheritance graph
[legend]
Collaboration diagram for cvr::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
virtual const std::string & name () const
virtual arctanLUTclone () const
virtual arctanLUTnewInstance () const

Protected Types

typedef const float * cfloatptr_

Static Protected Member Functions

static void constructArcTanLUT ()

Static Protected Attributes

static const cfloatptr_atanLUT_


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:

 cvr::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* cvr::arctanLUT::cfloatptr_ [protected]

Type required to create the LUT as a const structure.


Constructor & Destructor Documentation

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.


Member Function Documentation

virtual arctanLUT* cvr::arctanLUT::clone (  )  const [virtual]

Returns a pointer to a clone of the parameters.

Implements cvr::object.

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]

Returns the name of this class.

Implements cvr::object.

virtual arctanLUT* cvr::arctanLUT::newInstance (  )  const [virtual]

Returns a pointer to a clone of the parameters.

Implements cvr::object.

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.

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

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

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.

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

References atanLUT_, cvr::closeToZero(), and cvr::iround().

Referenced by operator()().


Member Data Documentation

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


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

Generated on Sun Sep 20 22:08:56 2009 for CVR-Lib by Doxygen 1.5.8