ldpk
Classes | Public Types | List of all members
ldpk::lookup_table< VEC2 > Class Template Reference

Use your own two-dimensional double-valued vector type as VEC2. More...

#include <ldpk_lookup_table.h>

Public Types

typedef lookup_table< VEC2 > this_type
 This class.
 
typedef VEC2 vec2_type
 Your two-dimensional double-valued vector type.
 

Public Member Functions

Initializing lookup table
 lookup_table ()
 
void init (int nx, int ny)
 Initialize a grid with nx * ny sample points. Implies reset().
 
void set_lens_center_fov (const vec2_type &lc_fov)
 Lens Center in normalized FOV-coordinates. LC is the fixed point of all distortion models. We use it as starting point for iterating through the grid. Default is (0.5,0.5).
 
Methods for building the lookup table

We denote the original unwarped point by p and the warped point by q. The lookup table is constructed like this: You implement a loop using reset() and next(). The table will give you the next position for warping by get_p_current_fov(). Then call the warp method in your distortion model instance using the initial value obtained by get_current_initial_value(). Finally enter the result (i.e. the warped position) in the lookup table by calling set_value()

void reset ()
 Use reset() and next() to build a loop for generating positions. See example.
 
bool next ()
 False means no value to be generated, loop is done. See example.
 
int get_ix_current () const
 Current x-position while painting.
 
int get_iy_current () const
 Current y-position while painting.
 
vec2_type get_p_current_fov () const
 Current position in normalized FOV-coordinates. This is the position you want to warp next, while building the lookup table.
 
vec2_type get_current_initial_value () const
 Appropriate initial value for calculating warp at current position obtained with get_p_current_fov().
 
void set_q_current_fov (const vec2_type &q_fov)
 Set value for given index pair. Index pairs out of bounds will raise an exception. Use this method to insert the warped position from warping p_current_fov.
 
Methods for taking benefit from the lookup table

When ::tde4_ld_plugin::distort(x0,y0,x1,y1) (i.e. without initial_values) is called, the lookup table is consulted. An initial value is obtained from get_initial_value(). Then tde4_ld_plugin::distort(x0,y0,x1,y1) calls tde4_ld_plugin::distort(x0,y0,x1s,y1s,x1,y1) where (x1s,y1s) is the initial value.

const vec2_typeget_value (int ix, int iy) const
 Direct access to table data, raises exception if index is out of bounds.
 
const vec2_typeget_value (const vec2_type &p_fov) const
 Once you have built the lookup table, use this method to extract an initial value from lookup table for the position specified in FOV-coordinates. Positions out of bounds will be clipped.
 
const vec2_typeget_initial_value (const vec2_type &p_fov) const
 Currently same as get_value(), but we might add more sophisticated methods to generate an initial value later.
 
Methods for debugging and testing
std::ostream & out_state (std::ostream &cout) const
 Visualizing the paint algo for debugging purposes.
 
std::ostream & out_gnuplot (std::ostream &cout) const
 Output as a vector field for gnuplot Use command "plot 'test.i' with vector" or similar in gnuplot.
 

Detailed Description

template<class VEC2>
class ldpk::lookup_table< VEC2 >

Use your own two-dimensional double-valued vector type as VEC2.


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