ex::Lattice
Encapsulates a lattice defined by two lattice vectors P and Q, an origin O, a barrel distortion Kb and a spiral distortion Ks. The vector L of a lattice point at index (h,k) is given by the following formula:
For zero distortion constants, this simplifies to L = O + h P + k Q. All values are dimensionless, but since a lattice is usually determined and/or used for an image, it's units should be considered to be pixels.
Interface
Construction
- Lattice()
- Default ctor, will set P to {1,0}, Q to {0,1}, and O to {0,0}
- Lattice(Vec2 P, Vec2 Q, Vec2 O=Vec2(0.0,0.0))
- Initialization with P and Q, the origin defaults to {0,0} if not explicitly given
Parameter Getter/Setter
These should be self-explanatory, P is the first and Q the second vector
- SetFirst(Vec2 P)
- Vec2 GetFirst()
- SetSecond(Vec2 Q)
- Vec2 GetSecond()
- SetOffset(Vec2 O)
- Vec2 GetOffset()
- SetBarrelDistortion(double)
- double GetBarrelDistortion()
- SetSpiralDistortion(double)
- double GetSpiralDistortion()
Operators
Lattice objects may be compared for equality and inequality, i.e. with == and !=.
Others
- Vec2 CalcPosition(Point hk)
- Calculates L based on the given integer (h,k) index
- Vec2 CalcPosition(Vec2 hk)
- Calculates L based on the given fractional (h,k) index
- Vec2 CalcComponents(Point xy)
- Determines the (fractional) (h,k) index at the given pixel position
- Vec2 CalcComponents(Vec2 xy)
- Determines the (fractional) (h,k) index at the given (fractional) pixel position
Functions
- Lattice InvertLattice(Lattice l)
-
Returns the inverted form of the given lattice, which is defined by
Examples
import ex lat=ex.Lattice(Vec2(10,0), Vec2(0,15), Vec2(50,50)) print lat.CalcPosition(Point(10,10)) lat.SetBarrelDistortion(1e-6) print lat.CalcPosition(Point(10,10))
back to the ex module overview
Attachments
- lattice_invert.png (11.2 kB) - added by ansgar on 06/17/07 12:21:21.
- lattice_equation.png (15.6 kB) - added by ansgar on 06/17/07 12:46:46.

