Laxkit
0.0.7.1
|
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. |
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)
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 | ||
) |
Simple copy transform dest[0..5]=src[0..5]. dest and src must both exist.
! Create a transform from a string. ! If m==NULL, then return a new double[6], else put result in m.
Referenced by LaxInterfaces::ObjectInterface::AddToSelection(), Laxkit::Affine::AnchorShear(), LaxInterfaces::MeasureInterface::duplicate(), Laxkit::Affine::Flip(), Laxkit::Affine::Invert(), LaxInterfaces::ObjectInterface::MouseMove(), LaxInterfaces::PatchInterface::MouseMove(), Laxkit::Affine::Multiply(), Laxkit::Displayer::Newangle(), Laxkit::Displayer::Newmag(), Laxkit::DisplayerCairo::NewTransform(), LaxInterfaces::ObjectInterface::PerformAction(), Laxkit::DisplayerCairo::PopAxes(), Laxkit::Affine::PreMultiply(), Laxkit::DisplayerCairo::PushAxes(), Laxkit::Affine::Rotate(), Laxkit::Affine::RotateScale(), Laxkit::Displayer::ShiftReal(), Laxkit::Displayer::ShiftScreen(), Laxkit::svgtransform(), Laxkit::Displayer::syncFromPanner(), Laxkit::transform_rotate(), LaxFiles::TransformAttribute(), and Laxkit::Displayer::Zoom().
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().
sx | size of x axis |
sy | size of y axis |
angle | rotation in radians of the xaxis from (1,0) |
shear | rotation in radians of the yaxis from transpose(xaxis) |
References norm(), rotate(), and transpose().
double * Laxkit::transform_invert | ( | double * | result, |
const double * | m | ||
) |
Invert m into result. If result==NULL, then return a new double[6].
[ a b 0 ] CTM=[ c d 0 ] –> [a b c d tx ty] [ tx ty 1 ]
{{d/(a*d-b*c), (-b)/(a*d-b*c), 0}, {(-c)/(a*d-b*c), a/(a*d-b*c), 0}, {(c*ty-d*tx)/(a*d-b*c), (b*tx-a*ty)/(a*d-b*c), 1}}
Referenced by Laxkit::Affine::AnchorShear(), Laxkit::bez_intersections(), Laxkit::DoublePanner::CenterReal(), Laxkit::DisplayerXlib::findictm(), Laxkit::Affine::Flip(), LaxInterfaces::RectInterface::Flip(), Laxkit::DisplayerCairo::Getictm(), Laxkit::Affine::Invert(), LaxInterfaces::PathsData::MatchTransform(), LaxInterfaces::ObjectInterface::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PatchInterface::MouseMove(), Laxkit::DoublePanner::Newangle(), Laxkit::DoublePanner::NewAxis(), Laxkit::DoublePanner::Newmag(), Laxkit::DoublePanner::NewTransform(), Laxkit::DisplayerCairo::NewTransform(), LaxInterfaces::ObjectInterface::PerformAction(), LaxInterfaces::GradientData::pointin(), LaxInterfaces::SomeData::pointin(), Laxkit::DoublePanner::PopAxes(), Laxkit::DisplayerCairo::PopAxes(), Laxkit::DoublePanner::PushAndNewTransform(), Laxkit::DoublePanner::PushAxes(), Laxkit::DoublePanner::Rotate(), Laxkit::Affine::RotateScale(), Laxkit::DoublePanner::ShiftReal(), Laxkit::DoublePanner::ShiftScreen(), Laxkit::DoublePanner::syncFromPanner(), Laxkit::transform_point_inverse(), LaxInterfaces::ObjectInterface::TransformSelection(), Laxkit::DoublePanner::Zoom(), and Laxkit::DoublePanner::Zoomr().
double * Laxkit::transform_mult | ( | double * | result, |
const double * | a, | ||
const double * | b | ||
) |
Multiply 2 6 member transform arrays: result = a x b.
The matrices are aligned like so:
[ a b 0 ] [ c d 0 ] –> [a b c d tx ty] [ tx ty 1 ]
If result is NULL, then return a new double[6] with the result. result should not point to the same place as m or n.
Referenced by Laxkit::Affine::AnchorShear(), Laxkit::Affine::Flip(), LaxInterfaces::RectInterface::Flip(), LaxInterfaces::PathsData::MatchTransform(), LaxInterfaces::ObjectInterface::MouseMove(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PatchInterface::MouseMove(), Laxkit::Affine::Multiply(), LaxInterfaces::ObjectInterface::PerformAction(), Laxkit::Affine::PreMultiply(), Laxkit::DoublePanner::PushAndNewTransform(), Laxkit::DisplayerXlib::PushAndNewTransform(), Laxkit::Displayer::PushAndNewTransform(), Laxkit::Affine::Rotate(), Laxkit::Affine::RotateScale(), Laxkit::svgtransform(), Laxkit::transform_rotate(), LaxFiles::TransformAttribute(), and LaxInterfaces::ObjectInterface::TransformSelection().
flatpoint Laxkit::transform_point | ( | const double * | m, |
double | x, | ||
double | y | ||
) |
Return point p transformed by matrix m. newpoint=[x,y,1]*m.
[ a b 0 ] M=[ c d 0 ] –> [a b c d tx ty] [ tx ty 1 ]
Referenced by Laxkit::DoubleBBox::addtobounds(), LaxInterfaces::PathsData::ApplyTransform(), Laxkit::bez_ellipse(), Laxkit::bez_intersections(), Laxkit::Displayer::Center(), LaxInterfaces::SomeData::fitto(), LaxInterfaces::RectInterface::Flip(), LaxInterfaces::GradientInterface::getpoint(), LaxInterfaces::RectInterface::getpoint(), LaxInterfaces::PatchData::grow(), Laxkit::DoubleBBox::intersect(), Laxkit::laximlib_image_out_matrix(), LaxInterfaces::PathsData::MatchTransform(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PatchInterface::MouseMove(), LaxInterfaces::PathInterface::MouseMove(), LaxInterfaces::GradientData::pointin(), LaxInterfaces::SomeData::pointin(), LaxInterfaces::ObjectInterface::PointInSelection(), Laxkit::DisplayerCairo::realtoscreen(), LaxInterfaces::PathInterface::realtoscreen(), LaxInterfaces::PatchInterface::Refresh(), LaxInterfaces::PatchData::renderToBuffer(), Laxkit::Affine::Scale(), LaxInterfaces::GradientInterface::scan(), LaxInterfaces::RectInterface::scan(), LaxInterfaces::PointWarpInterface::scan(), LaxInterfaces::PatchInterface::scan(), LaxInterfaces::PathInterface::scan(), LaxInterfaces::PathInterface::scanEndpoints(), LaxInterfaces::PathInterface::scanHover(), and Laxkit::DisplayerCairo::screentoreal().
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 ]
Return point p transformed by the inverse of matrix m. newpoint=[x,y,1]*m^-1.
[ a b 0 ] M=[ c d 0 ] –> [a b c d tx ty] [ tx ty 1 ]
References Laxkit::transform_invert().
Referenced by LaxInterfaces::PathInterface::AddPoint(), LaxInterfaces::GradientInterface::LBDown(), LaxInterfaces::RectInterface::LBDown(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PointWarpInterface::MouseMove(), LaxInterfaces::PatchInterface::MouseMove(), LaxInterfaces::PathInterface::MouseMove(), Laxkit::Affine::Scale(), LaxInterfaces::GradientInterface::scan(), LaxInterfaces::RectInterface::scan(), LaxInterfaces::PathInterface::scanHover(), and LaxInterfaces::PathInterface::screentoreal().
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().
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().