Laxkit  0.0.7.1
Functions
Transform math

Functions

void Laxkit::dumpctm (const double *d)
 Write out the transform d to cout, or to cerr if DBG is enabled.
double * Laxkit::transform_identity (double *result)
 Return identity matrix. If result==NULL, then return a new'd double[6].
double * Laxkit::transform_invert (double *result, const double *m)
 Invert m into result. If result==NULL, then return a new double[6].
double * Laxkit::transform_mult (double *result, const double *a, const double *b)
 Multiply 2 6 member transform arrays: result = a x b.
double * Laxkit::transform_rotate (double *m, double angle)
 Rotate m by angle. If m==NULL, then return a new'd double[6] with rotation angle.
double * Laxkit::transform_from_basis (double *result, flatpoint o, flatpoint x, flatpoint y)
 Find a transform from the given flat basis. Return new double[6] if result==NULL.
void Laxkit::transform_to_basis (double *m, flatpoint *o, flatpoint *x, flatpoint *y)
 Decompose a transform to an origin, x axis, and y axis.
double * Laxkit::transform_from_basics (double *result, double x, double y, double sx, double sy, double angle, double shear)
 ***imp me! Compose a transform from a position, x scale, y scale, rotation, and "shear".
void Laxkit::transform_to_basics (double *m, double *x, double *y, double *sx, double *sy, double *ang, double *shear)
 Decompose a transform to simple measures of position, x scale, y scale, rotation, and "shear".
double * Laxkit::transform_set (double *m, double a, double b, double c, double d, double x0, double y0)
 Simple set m[]={a,b,c,d,x0,y0}.
void Laxkit::transform_copy (double *dest, const double *src)
 Simple copy transform dest[0..5]=src[0..5]. dest and src must both exist.
flatpoint Laxkit::transform_point_inverse (const double *m, flatpoint p)
 Return point p transformed by the inverse of matrix m. newpoint=[x,y,1]*m^-1.
flatpoint Laxkit::transform_point (const double *m, double x, double y)
 Return point p transformed by matrix m. newpoint=[x,y,1]*m.
flatpoint Laxkit::transform_point (const double *m, flatpoint p)
 Return point p transformed by matrix m. newpoint=[p.x,p.y,1]*m.
flatpoint Laxkit::transform_vector (const double *m, flatpoint p)
 Return vector p transformed by matrix m. newpoint=[p.x,p.y,0]*m. Basically rotate+scale+shear, no translate.

Detailed Description

The Affine class, and (essentially C) functions to manipulate double[6] arrays corresponding to a 2 dimensional affine transform. These are used, for instance, in Displayer and SomeData.

      [ a  b  0 ]
      [ c  d  0 ]  –> [a b c d tx ty]
      [ tx ty 1 ]
  screen x= ax + cy + tx  –> screen = [x',y',1] = [x,y,1] * CTM  = real * CTM
  screen y= bx + dy + ty
 So (transformed coord) == (original coord) * Matrix
 To demonstrate a common usage scenario,
 Suppose you have 2 objects with transforms M1 and M2. (coord)*M1 turns an object 1 
 coordinate into its parent space coordinates, and similarly for object 2.
 The matrix you need to transform object 1 coordinates into object 2 coordinates is then:
   M1 x inverse(M2)
 So the coordinate in object 2 == (object 1 coord) x M1 x inverse(M2)
 

Function Documentation

void Laxkit::dumpctm ( const double *  d)

Write out the transform d to cout, or to cerr if DBG is enabled.

Referenced by Laxkit::DoublePanner::syncFromPanner(), and Laxkit::Displayer::syncFromPanner().

void Laxkit::transform_copy ( double *  dest,
const double *  src 
)
double * Laxkit::transform_from_basics ( double *  result,
double  x,
double  y,
double  sx,
double  sy,
double  angle,
double  shear 
)

***imp me! Compose a transform from a position, x scale, y scale, rotation, and "shear".

Rotation is the rotation of the x axis. Shear, in this case, is taken to mean the angle that the y axis differs from the transpose of the x axis. y scale is the scale in the y axis AFTER shear.

create a new double[6] if result does not exist.

This is the reverse of transform_to_basics().

Todo:
*** finish me!
Parameters:
sxsize of x axis
sysize of y axis
anglerotation in radians of the xaxis from (1,0)
shearrotation in radians of the yaxis from transpose(xaxis)

References norm(), rotate(), and transpose().

double * Laxkit::transform_invert ( double *  result,
const double *  m 
)
double * Laxkit::transform_mult ( double *  result,
const double *  a,
const double *  b 
)
flatpoint Laxkit::transform_point ( const double *  m,
double  x,
double  y 
)
flatpoint Laxkit::transform_point ( const double *  m,
flatpoint  p 
)

Return point p transformed by matrix m. newpoint=[p.x,p.y,1]*m.

      [ a  b  0 ]
    M=[ c  d  0 ]  –> [a b c d tx ty]
      [ tx ty 1 ]
 
flatpoint Laxkit::transform_point_inverse ( const double *  m,
flatpoint  p 
)
double * Laxkit::transform_rotate ( double *  m,
double  angle 
)

Rotate m by angle. If m==NULL, then return a new'd double[6] with rotation angle.

If m is supplied, then m becomes rotation*m.

References Laxkit::transform_copy(), Laxkit::transform_identity(), and Laxkit::transform_mult().

Referenced by LaxInterfaces::PatchInterface::MouseMove().

double * Laxkit::transform_set ( double *  m,
double  a,
double  b,
double  c,
double  d,
double  x0,
double  y0 
)

Simple set m[]={a,b,c,d,x0,y0}.

If m==NULL, then return a new'd double[6]

Referenced by Laxkit::Affine::Flip(), LaxInterfaces::RectInterface::Flip(), LaxInterfaces::PatchInterface::MouseMove(), and LaxFiles::TransformAttribute().

void Laxkit::transform_to_basics ( double *  m,
double *  x,
double *  y,
double *  sx,
double *  sy,
double *  ang,
double *  shear 
)

Decompose a transform to simple measures of position, x scale, y scale, rotation, and "shear".

This returns values that will produce the same m when fed back into transform_from_basics().

References angle(), norm(), and transpose().

flatpoint Laxkit::transform_vector ( const double *  m,
flatpoint  p 
)

Return vector p transformed by matrix m. newpoint=[p.x,p.y,0]*m. Basically rotate+scale+shear, no translate.

Referenced by Laxkit::Affine::transformVector().


Mon Feb 17 2014 11:52:58, Laxkit