Encapsulates a lattice defined by two lattice vectors \vec{a} and \vec{b}, an origin \vec{o}, a barrel distortion K_{b} and a spiral distortion K_{s}. The vector \vec{l} of a lattice point at index (h,k) is given by the following formula:
\vec{l}=\vec{o}+\left(\begin{array}{cc} 1+K_{b}\left|h\vec{a}+k\vec{b}\right|^{2} & K_{s}\left|h\vec{a}+k\vec{b}\right|^{2}\\ -K_{s}\left|h\vec{a}+k\vec{b}\right|^{2} & 1+K_{b}\left|h\vec{a}+k\vec{b}\right|^{2} \end{array}\right)\left(h\vec{a}+k\vec{b}\right)
For zero distortion constants, this simplifies to \vec{l}=\vec{o}+h\vec{a}+k\vec{b}. 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.
import iplt
lat=iplt.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))
A lattice consists of two non-parallel vectors and a specific offset. Since it is usually associated with an image, its units are meant to be pixels!
returns the lattice components of a point
returns position based on index
calc distance of a point to nearest lattice point
returns barrel distortion
returns first vector
returns offset vector
returns second vector
returns spiral distortion
sets barrel distortion
sets first vector
sets offset vector
sets second vector
sets spiral distortion
default is {1,0} {0,1} {0,0}
invert domain of lattice spatial <-> reciprocal
The inversion is defined by:
P_{inv}=\frac{1}{D}\left(\begin{array}{cc} -q_y \\ q_x \end{array}\right),Q_{inv}=\frac{1}{D}\left(\begin{array}{cc} p_y \\ -p_x \end{array}\right), D=p_yq_x-p_xq_y