Inkscape
Vector Graphics Editor
Geom::Affine Class Reference

3x3 matrix representing an affine transformation. More...

#include <affine.h>

Inheritance diagram for Geom::Affine:

Public Member Functions

 Affine ()
 
 Affine (Coord c0, Coord c1, Coord c2, Coord c3, Coord c4, Coord c5)
 Create a matrix from its coefficient values. More...
 
Coord operator[] (unsigned i) const
 Access a coefficient by its index. More...
 
Coordoperator[] (unsigned i)
 
bool operator== (Affine const &o) const
 
Combine with other transformations
Affineoperator*= (Affine const &m)
 Combine this transformation with another one. More...
 
Affineoperator*= (Translate const &t)
 Combine this transformation with a translation. More...
 
Affineoperator*= (Scale const &s)
 Combine this transformation with scaling. More...
 
Affineoperator*= (Rotate const &r)
 Combine this transformation a rotation. More...
 
Affineoperator*= (HShear const &h)
 Combine this transformation with horizontal shearing (skew). More...
 
Affineoperator*= (VShear const &v)
 Combine this transformation with vertical shearing (skew). More...
 
Affineoperator*= (Zoom const &)
 
Get the parameters of the matrix's transform
Point xAxis () const
 
Point yAxis () const
 
Point translation () const
 Gets the translation imparted by the Affine. More...
 
Coord expansionX () const
 Calculates the amount of x-scaling imparted by the Affine. More...
 
Coord expansionY () const
 Calculates the amount of y-scaling imparted by the Affine. More...
 
Point expansion () const
 
Modify the matrix
void setXAxis (Point const &vec)
 
void setYAxis (Point const &vec)
 
void setTranslation (Point const &loc)
 Sets the translation imparted by the Affine. More...
 
void setExpansionX (Coord val)
 
void setExpansionY (Coord val)
 
void setIdentity ()
 Sets this matrix to be the Identity Affine. More...
 
Inspect the matrix's transform
bool isIdentity (Coord eps=EPSILON) const
 Check whether this matrix is an identity matrix. More...
 
bool isTranslation (Coord eps=EPSILON) const
 Check whether this matrix represents a pure translation. More...
 
bool isScale (Coord eps=EPSILON) const
 Check whether this matrix represents pure scaling. More...
 
bool isUniformScale (Coord eps=EPSILON) const
 Check whether this matrix represents pure uniform scaling. More...
 
bool isRotation (Coord eps=EPSILON) const
 Check whether this matrix represents a pure rotation. More...
 
bool isHShear (Coord eps=EPSILON) const
 Check whether this matrix represents pure horizontal shearing. More...
 
bool isVShear (Coord eps=EPSILON) const
 Check whether this matrix represents pure vertical shearing. More...
 
bool isNonzeroTranslation (Coord eps=EPSILON) const
 Check whether this matrix represents a pure nonzero translation. More...
 
bool isNonzeroScale (Coord eps=EPSILON) const
 Check whether this matrix represents pure, nonzero scaling. More...
 
bool isNonzeroUniformScale (Coord eps=EPSILON) const
 Check whether this matrix represents pure, nonzero uniform scaling. More...
 
bool isNonzeroRotation (Coord eps=EPSILON) const
 Check whether this matrix represents a pure, nonzero rotation. More...
 
bool isNonzeroNonpureRotation (Coord eps=EPSILON) const
 Check whether this matrix represents a non-zero rotation about any point. More...
 
Point rotationCenter () const
 For a (possibly non-pure) non-zero-rotation matrix, calculate the rotation center. More...
 
bool isNonzeroHShear (Coord eps=EPSILON) const
 Check whether this matrix represents pure, nonzero horizontal shearing. More...
 
bool isNonzeroVShear (Coord eps=EPSILON) const
 Check whether this matrix represents pure, nonzero vertical shearing. More...
 
bool isZoom (Coord eps=EPSILON) const
 Check whether this matrix represents zooming. More...
 
bool preservesArea (Coord eps=EPSILON) const
 Check whether the transformation preserves areas of polygons. More...
 
bool preservesAngles (Coord eps=EPSILON) const
 Check whether the transformation preserves angles between lines. More...
 
bool preservesDistances (Coord eps=EPSILON) const
 Check whether the transformation preserves distances between points. More...
 
bool flips () const
 Check whether this transformation flips objects. More...
 
bool isSingular (Coord eps=EPSILON) const
 Check whether this matrix is singular. More...
 
Compute other matrices
Affine withoutTranslation () const
 
Affine inverse () const
 Compute the inverse matrix. More...
 
Compute scalar values
Coord det () const
 Calculate the determinant. More...
 
Coord descrim2 () const
 Calculate the square of the descriminant. More...
 
Coord descrim () const
 Calculate the descriminant. More...
 

Static Public Member Functions

static Affine identity ()
 

Private Attributes

Coord _c [6]
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &out_file, const Geom::Affine &m)
 Print out the Affine (for debugging). More...
 
Affine identity ()
 Create an identity matrix. More...
 
Affine elliptic_quadratic_form (Affine const &m)
 Given a matrix m such that unit_circle = m*x, this returns the quadratic form x*A*x = 1. More...
 
bool are_near (Affine const &a, Affine const &b, Coord eps)
 Nearness predicate for affine transforms. More...
 

Detailed Description

3x3 matrix representing an affine transformation.

Affine transformations on elements of a vector space are transformations which can be expressed in terms of matrix multiplication followed by addition ( \(x \mapsto A x + b\)). They can be thought of as generalizations of linear functions ( \(y = a x + b\)) to vector spaces. Affine transformations of points on a 2D plane preserve the following properties:

  • Colinearity: if three points lie on the same line, they will still be colinear after an affine transformation.
  • Ratios of distances between points on the same line are preserved
  • Parallel lines remain parallel.

All affine transformations on 2D points can be written as combinations of scaling, rotation, shearing and translation. They can be represented as a combination of a vector and a 2x2 matrix, but this form is inconvenient to work with. A better solution is to represent all affine transformations on the 2D plane as 3x3 matrices, where the last column has fixed values.

\[ A = \left[ \begin{array}{ccc} c_0 & c_1 & 0 \\ c_2 & c_3 & 0 \\ c_4 & c_5 & 1 \end{array} \right]\]

We then interpret points as row vectors of the form \([p_X, p_Y, 1]\). Applying a transformation to a point can be written as right-multiplication by a 3x3 matrix ( \(p' = pA\)). This subset of matrices is closed under multiplication - combination of any two transforms can be expressed as the multiplication of their matrices. In this representation, the \(c_4\) and \(c_5\) coefficients represent the translation component of the transformation.

Matrices can be multiplied by other more specific transformations. When multiplying, the transformations are applied from left to right, so for example m = a * b means: m first transforms by a, then by b.

Definition at line 60 of file affine.h.

Constructor & Destructor Documentation

◆ Affine() [1/2]

Geom::Affine::Affine ( )
inline

Definition at line 73 of file affine.h.

References _c.

Referenced by operator*=().

◆ Affine() [2/2]

Geom::Affine::Affine ( Coord  c0,
Coord  c1,
Coord  c2,
Coord  c3,
Coord  c4,
Coord  c5 
)
inline

Create a matrix from its coefficient values.

It's rather inconvenient to directly create matrices in this way. Use transform classes if your transformation has a geometric interpretation.

See also
Translate
Scale
Rotate
HShear
VShear
Zoom

Definition at line 87 of file affine.h.

References _c.

Member Function Documentation

◆ descrim()

Coord Geom::Affine::descrim ( ) const

Calculate the descriminant.

If the matrix doesn't contain a shearing or non-uniform scaling component, this value says how will the length of any line segment change after applying this transformation to arbitrary objects on a plane. The new length will be

line_seg.length() * m.descrim())
static const Triplet m[3]
Definition: hsluv.cpp:44
Returns
\(\sqrt{|\det A|}\).

Definition at line 434 of file affine.cpp.

References descrim2(), and Geom::sqrt().

Referenced by Inkscape::UI::PathManipulator::_getStrokeTolerance(), Inkscape::UI::Tools::PencilTool::_interpolate(), Inkscape::UI::Tools::PencilTool::_sketchInterpolate(), _ungroup_compensate_source_transform(), Inkscape::CanvasItemGridAxonom::_update(), Inkscape::DrawingGlyphs::_updateItem(), Inkscape::UI::Tools::PencilTool::addPowerStrokePencil(), Inkscape::UI::Dialog::CloneTiler::apply(), Inkscape::UI::Widget::calcScaleLineWidth(), Inkscape::CanvasItemBpath::closest_distance_to(), SPText::description(), Inkscape::LivePathEffect::LPEOffset::doBeforeEffect(), Inkscape::LivePathEffect::LPESimplify::doEffect(), SPItem::doWriteTransform(), Inkscape::UI::Tools::SpiralTool::finishItem(), Inkscape::UI::Tools::StarTool::finishItem(), Inkscape::CanvasItemRect::get_shadow_size(), SPDesktop::DesktopAffine::getZoom(), item_find_paths(), Inkscape::UI::Toolbar::TextToolbar::lineheight_unit_changed(), Inkscape::LivePathEffect::lpe_shape_revert_stroke_and_fill(), modify_filter_gaussian_blur_from_item(), new_filter_simple_from_item(), objects_query_blur(), objects_query_fontnumbers(), objects_query_strokewidth(), Geom::Ellipse::operator*=(), Inkscape::LivePathEffect::ScalarParam::param_transform_multiply(), Inkscape::LivePathEffect::PowerStrokePointArrayParam::param_transform_multiply(), path_simplify(), SPPath::removeTransformsRecursively(), Inkscape::Filters::FilterDiffuseLighting::render_cairo(), Inkscape::Filters::FilterSpecularLighting::render_cairo(), SPOffset::set_shape(), SPLine::set_transform(), SPPath::set_transform(), SPText::set_transform(), SPGenericEllipse::set_transform(), SPFlowtext::set_transform(), Inkscape::UI::Widget::StrokeStyle::setStrokeDash(), sp_desktop_apply_css_recursive(), sp_gradient_convert_to_userspace(), sp_selected_path_create_offset_object(), sp_selected_path_do_offset(), sp_svg_transform_write(), sp_te_adjust_kerning_screen(), sp_te_adjust_linespacing_screen(), sp_te_adjust_rotation_screen(), sp_te_apply_style(), Inkscape::UI::Tools::sp_tweak_color_recursive(), Inkscape::UI::Tools::sp_tweak_dilate_recursive(), Inkscape::Extension::Internal::PrintLatex::stroke(), stroke_average_width(), take_style_from_item(), text_flow_into_shape(), Inkscape::UI::Toolbar::TextToolbar::text_outer_set_style(), text_put_on_path(), Inkscape::DrawingItem::update(), SPHatchPath::update(), SPShape::update(), and wrap_transforms().

◆ descrim2()

Coord Geom::Affine::descrim2 ( ) const

Calculate the square of the descriminant.

This is simply the absolute value of the determinant.

Returns
\(|\det A|\).

Definition at line 424 of file affine.cpp.

References det().

Referenced by Geom::Parallelogram::area(), descrim(), PatternKnotHolderEntityScale::knot_grabbed(), preservesArea(), and wrap_transforms().

◆ det()

Coord Geom::Affine::det ( ) const

◆ expansion()

Point Geom::Affine::expansion ( ) const
inline

Definition at line 123 of file affine.h.

References expansionX(), and expansionY().

◆ expansionX()

◆ expansionY()

◆ flips()

bool Geom::Affine::flips ( ) const

Check whether this transformation flips objects.

A transformation flips objects if it has a negative scaling component.

Definition at line 368 of file affine.cpp.

References det().

Referenced by Geom::TEST().

◆ identity()

static Affine Geom::Affine::identity ( )
inlinestatic

◆ inverse()

Affine Geom::Affine::inverse ( ) const

Compute the inverse matrix.

Inverse is a matrix (denoted \(A^{-1}\)) such that \(AA^{-1} = A^{-1}A = I\). Singular matrices have no inverse (for example a matrix that has two of its columns equal). For such matrices, the identity matrix will be returned instead.

Parameters
epsNumerical tolerance
Returns
Inverse of the matrix, or the identity matrix if the inverse is undefined.
Postcondition
(m * m.inverse()).isIdentity() == true

Definition at line 388 of file affine.cpp.

References _c, det(), Geom::max(), Geom::rel_error_bound(), setIdentity(), and Geom::sqrt().

Referenced by SPHatch::_calculateStripExtents(), Inkscape::UI::PathManipulator::_createGeometryFromControlPoints(), Inkscape::Extension::Internal::CairoRenderContext::_createHatchPainter(), Inkscape::UI::PathManipulator::_externalChange(), Inkscape::Extension::Internal::SvgBuilder::_getClip(), Inkscape::UI::Dialog::GuidelinePropertiesDialog::_modeChanged(), Inkscape::DrawingImage::_pickItem(), Inkscape::UI::Tools::EraserTool::_probeUnlinkCutClonedGroup(), Inkscape::DrawingText::_renderItem(), Inkscape::UI::Tools::TextTool::_setupText(), _ungroup_compensate_source_transform(), SPDesktop::DesktopAffine::_update(), Inkscape::UI::PathManipulator::_updateDragPoint(), Inkscape::LivePathEffect::LPETiling::addCanvasIndicators(), Inkscape::Extension::Internal::SvgBuilder::addShadedFill(), SPItem::adjust_paint_recursive(), Inkscape::UI::Dialog::CloneTiler::apply(), Inkscape::ObjectSet::applyAffine(), Inkscape::UI::Widget::Graphics::check_single_page(), Inkscape::CanvasItemBpath::closest_distance_to(), Inkscape::CanvasItemBpath::contains(), Geom::Parallelogram::contains(), Inkscape::DrawingMeshGradient::create_pattern(), SPImage::cropToArea(), Inkscape::UI::Tools::do_trace(), Inkscape::LivePathEffect::LPETiling::doAfterEffect(), Inkscape::LivePathEffect::LPEFillBetweenMany::doBeforeEffect(), Inkscape::LivePathEffect::LPEFillBetweenStrokes::doBeforeEffect(), Inkscape::LivePathEffect::LPEMeasureSegments::doBeforeEffect(), Inkscape::LivePathEffect::LPEMirrorSymmetry::doBeforeEffect(), Inkscape::LivePathEffect::LPEBool::doEffect(), Inkscape::LivePathEffect::LPETiling::doEffect_path(), Inkscape::LivePathEffect::LPEVonKoch::doEffect_path(), Inkscape::LivePathEffect::LPETiling::doEffect_path_post(), Inkscape::LivePathEffect::LPERoughHatches::doEffect_pwd2(), Inkscape::LivePathEffect::LPEFilletChamfer::doOnApply(), Inkscape::LivePathEffect::LPETiling::doOnVisibilityToggled(), PdfParser::doShadingPatternFillFallback(), SPItem::doWriteTransform(), Inkscape::UI::Tools::SpiralTool::drag(), Inkscape::UI::Tools::ArcTool::drag(), Inkscape::UI::Tools::RectTool::drag(), Inkscape::UI::Tools::StarTool::drag(), Inkscape::UI::TransformHandle::dragged(), SPItem::dt2i_affine(), SPShape::either_bbox(), Inkscape::UI::Widget::CairoGraphics::fast_snapshot_combine(), file_import(), Inkscape::LivePathEffect::findShadowedTime(), Inkscape::LivePathEffect::LPEPts2Ellipse::genFitEllipse(), SPBox3D::get_center_screen(), SPBox3D::get_corner_screen(), Inkscape::Filters::FilterUnits::get_matrix_display2pb(), Inkscape::Filters::FilterUnits::get_matrix_pb2display(), Inkscape::UI::Dialog::CloneTiler::get_transform(), Inkscape::Extension::Internal::getODFItemTransform(), i2i_affine(), Geom::intersect_polish_root(), Geom::Parallelogram::intersects(), PatternKnotHolderEntityScale::knot_grabbed(), KnotHolder::knot_grabbed_handler(), KnotHolder::knot_moved_handler(), HatchKnotHolderEntityScale::knot_set(), KnotHolder::knot_ungrabbed_handler(), Shape::MakeTweak(), SPUse::move_compensate(), GrDragger::moveMeshHandles(), PatternKnotHolderEntity::offset_to_cell(), Geom::Ellipse::operator*=(), Inkscape::LivePathEffect::GroupBBoxEffect::original_bbox(), Inkscape::UI::Widget::CairoGraphics::paint_widget(), Inkscape::LivePathEffect::PathParam::paste_param_path(), Inkscape::ObjectSet::pathBoolOp(), Inkscape::UI::PathManipulator::PathManipulator(), Inkscape::LivePathEffect::LPEMeasureSegments::processObjects(), Inkscape::ObjectSet::relink(), SPPath::removeTransformsRecursively(), Inkscape::Filters::FilterImage::render_cairo(), Inkscape::Filters::FilterTurbulence::render_cairo(), Inkscape::DrawingPattern::renderPattern(), SPConnEndPair::reroutePathFromLibavoid(), Inkscape::UI::Tools::ToolBase::root_handler(), SPItem::rotate_rel(), Inkscape::UI::Dialog::rotateAround(), SPGroup::scaleChildItemsRec(), SPGradient::set_gs2d_matrix(), SPItem::set_i2d_affine(), Inkscape::UI::Tools::CalligraphicTool::set_to_accumulated(), SPImage::set_transform(), SPText::set_transform(), SPGenericEllipse::set_transform(), SPFlowtext::set_transform(), SPRect::set_transform(), SPSpiral::set_transform(), SPStar::set_transform(), Inkscape::UI::PathManipulator::setControlsTransform(), Inkscape::UI::Tools::MeasureTool::setLine(), Inkscape::ObjectSet::setMask(), Inkscape::UI::Tools::MeasureTool::setMeasureItem(), Inkscape::UI::Tools::MeasureTool::setPoint(), Inkscape::UI::Widget::RegisteredTransformedPoint::setValue(), Inkscape::BooleanBuilder::shape_commit(), Inkscape::Text::Layout::showGlyphs(), Inkscape::UI::Tools::MeasureTool::showInfoBox(), SPItem::skew_rel(), Inkscape::UI::Widget::CairoGraphics::snapshot_combine(), Inkscape::UI::Widget::Stores::snapshot_combine(), Inkscape::Extension::Internal::sp_asbitmap_render(), Inkscape::UI::Tools::sp_flood_do_flood_fill(), sp_gradient_convert_to_userspace(), sp_gradient_pattern_common_setup(), sp_import_document(), sp_item_gradient_set_coords(), sp_offset_move_compensate(), sp_selection_paste_impl(), Inkscape::UI::Tools::sp_spray_transform_path(), sp_te_get_position_by_coords(), sp_usepath_move_compensate(), Inkscape::UI::Tools::spdc_create_single_dot(), Inkscape::UI::Tools::spdc_flush_white(), Inkscape::LivePathEffect::LPESlice::splititem(), Inkscape::SelTrans::stamp(), Inkscape::UI::Widget::Stores::take_snapshot(), Geom::TEST(), Inkscape::ObjectSet::tile(), Inkscape::LivePathEffect::LPEBendPath::transform_multiply(), Inkscape::LivePathEffect::LPEBool::transform_multiply(), Inkscape::LivePathEffect::LPEOffset::transform_multiply(), Inkscape::LivePathEffect::LPEFillBetweenMany::transform_multiply_nested(), Inkscape::LivePathEffect::LPEFillBetweenStrokes::transform_multiply_nested(), Inkscape::UI::Tools::tweak_colors_in_gradient(), Inkscape::DrawingItem::update(), Inkscape::LivePathEffect::LPEFilletChamfer::updateAmount(), and wrap_transforms().

◆ isHShear()

bool Geom::Affine::isHShear ( Coord  eps = EPSILON) const

Check whether this matrix represents pure horizontal shearing.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} 1 & 0 & 0 \\ k & 1 & 0 \\ 0 & 0 & 1 \end{array}\right]\).

Definition at line 256 of file affine.cpp.

References _c, and are_near().

Referenced by sp_svg_transform_write(), and Geom::TEST().

◆ isIdentity()

◆ isNonzeroHShear()

bool Geom::Affine::isNonzeroHShear ( Coord  eps = EPSILON) const

Check whether this matrix represents pure, nonzero horizontal shearing.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} 1 & 0 & 0 \\ k & 1 & 0 \\ 0 & 0 & 1 \end{array}\right]\) and \(k \neq 0\).

Definition at line 268 of file affine.cpp.

References _c, and are_near().

Referenced by Geom::TEST().

◆ isNonzeroNonpureRotation()

bool Geom::Affine::isNonzeroNonpureRotation ( Coord  eps = EPSILON) const

Check whether this matrix represents a non-zero rotation about any point.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a & b & 0 \\ -b & a & 0 \\ c & d & 1 \end{array}\right]\), \(a^2 + b^2 = 1\) and \(a \neq 1\).

Definition at line 233 of file affine.cpp.

References _c, and are_near().

Referenced by Geom::TEST().

◆ isNonzeroRotation()

bool Geom::Affine::isNonzeroRotation ( Coord  eps = EPSILON) const

Check whether this matrix represents a pure, nonzero rotation.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a & b & 0 \\ -b & a & 0 \\ 0 & 0 & 1 \end{array}\right]\), \(a^2 + b^2 = 1\) and \(a \neq 1\).

Definition at line 219 of file affine.cpp.

References _c, and are_near().

Referenced by Geom::TEST().

◆ isNonzeroScale()

bool Geom::Affine::isNonzeroScale ( Coord  eps = EPSILON) const

Check whether this matrix represents pure, nonzero scaling.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a & 0 & 0 \\ 0 & b & 0 \\ 0 & 0 & 1 \end{array}\right]\) and \(a, b \neq 1\).

Definition at line 160 of file affine.cpp.

References _c, are_near(), and isSingular().

Referenced by Geom::TEST().

◆ isNonzeroTranslation()

bool Geom::Affine::isNonzeroTranslation ( Coord  eps = EPSILON) const

Check whether this matrix represents a pure nonzero translation.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ a & b & 1 \end{array}\right]\) and \(a, b \neq 0\)

Definition at line 134 of file affine.cpp.

References _c, and are_near().

Referenced by Geom::TEST().

◆ isNonzeroUniformScale()

bool Geom::Affine::isNonzeroUniformScale ( Coord  eps = EPSILON) const

Check whether this matrix represents pure, nonzero uniform scaling.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a_1 & 0 & 0 \\ 0 & a_2 & 0 \\ 0 & 0 & 1 \end{array}\right]\) where \(|a_1| = |a_2|\) and \(a_1, a_2 \neq 1\).

Definition at line 189 of file affine.cpp.

References _c, are_near(), and isSingular().

Referenced by SPFlowtext::set_transform(), and Geom::TEST().

◆ isNonzeroVShear()

bool Geom::Affine::isNonzeroVShear ( Coord  eps = EPSILON) const

Check whether this matrix represents pure, nonzero vertical shearing.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} 1 & k & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array}\right]\) and \(k \neq 0\).

Definition at line 294 of file affine.cpp.

References _c, and are_near().

Referenced by Geom::TEST().

◆ isRotation()

bool Geom::Affine::isRotation ( Coord  eps = EPSILON) const

Check whether this matrix represents a pure rotation.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a & b & 0 \\ -b & a & 0 \\ 0 & 0 & 1 \end{array}\right]\) and \(a^2 + b^2 = 1\).

Definition at line 206 of file affine.cpp.

References _c, and are_near().

Referenced by sp_svg_transform_write(), Geom::TEST(), and wrap_transforms().

◆ isScale()

bool Geom::Affine::isScale ( Coord  eps = EPSILON) const

Check whether this matrix represents pure scaling.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a & 0 & 0 \\ 0 & b & 0 \\ 0 & 0 & 1 \end{array}\right]\).

Definition at line 147 of file affine.cpp.

References _c, are_near(), and isSingular().

Referenced by Geom::Ellipse::operator*=(), sp_svg_transform_write(), Geom::TEST(), and wrap_transforms().

◆ isSingular()

bool Geom::Affine::isSingular ( Coord  eps = EPSILON) const

Check whether this matrix is singular.

Singular matrices have no inverse, which means that applying them to a set of points results in a loss of information.

Parameters
epsNumerical tolerance
Returns
True iff the determinant is near zero.

Definition at line 377 of file affine.cpp.

References are_near(), and det().

Referenced by Inkscape::UI::ControlPointSelection::_pointDragged(), Inkscape::UI::Dialog::Transformation::applyPageTransform(), Geom::Parallelogram::contains(), Inkscape::UI::TransformHandle::dragged(), Geom::Parallelogram::intersects(), isNonzeroScale(), isNonzeroUniformScale(), isScale(), isUniformScale(), isZoom(), preservesAngles(), Inkscape::DrawingItem::render(), Inkscape::UI::Widget::RegisteredTransformedPoint::setTransform(), and Geom::TEST().

◆ isTranslation()

bool Geom::Affine::isTranslation ( Coord  eps = EPSILON) const

Check whether this matrix represents a pure translation.

Will return true for the identity matrix, which represents a zero translation.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ a & b & 1 \end{array}\right]\)

Definition at line 123 of file affine.cpp.

References _c, and are_near().

Referenced by Inkscape::Filters::FilterSlot::_get_transformed_source_graphic(), Inkscape::ObjectSet::applyAffine(), SPItem::doWriteTransform(), Inkscape::Filters::FilterSlot::FilterSlot(), SPPage::movePage(), Inkscape::DrawingCache::prepare(), sp_svg_transform_write(), Geom::TEST(), Inkscape::ObjectSet::toSymbol(), Inkscape::LivePathEffect::LPEOffset::transform_multiply(), and wrap_transforms().

◆ isUniformScale()

bool Geom::Affine::isUniformScale ( Coord  eps = EPSILON) const

Check whether this matrix represents pure uniform scaling.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a_1 & 0 & 0 \\ 0 & a_2 & 0 \\ 0 & 0 & 1 \end{array}\right]\) where \(|a_1| = |a_2|\).

Definition at line 174 of file affine.cpp.

References _c, are_near(), and isSingular().

Referenced by SPLPEItem::optimizeTransforms(), SPSpiral::set_transform(), SPStar::set_transform(), Geom::TEST(), and wrap_transforms().

◆ isVShear()

bool Geom::Affine::isVShear ( Coord  eps = EPSILON) const

Check whether this matrix represents pure vertical shearing.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} 1 & k & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array}\right]\).

Definition at line 281 of file affine.cpp.

References _c, and are_near().

Referenced by sp_svg_transform_write(), and Geom::TEST().

◆ isZoom()

bool Geom::Affine::isZoom ( Coord  eps = EPSILON) const

Check whether this matrix represents zooming.

Zooming is any combination of translation and uniform non-flipping scaling. It preserves angles, ratios of distances between arbitrary points and unit vectors of line segments.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is invertible and of the form \(\left[\begin{array}{ccc} a & 0 & 0 \\ 0 & a & 0 \\ b & c & 1 \end{array}\right]\).

Definition at line 310 of file affine.cpp.

References _c, are_near(), and isSingular().

Referenced by Geom::TEST().

◆ operator*=() [1/7]

Affine & Geom::Affine::operator*= ( Affine const &  o)

Combine this transformation with another one.

After this operation, the matrix will correspond to the transformation obtained by first applying the original version of this matrix, and then applying m.

Definition at line 442 of file affine.cpp.

References _c.

◆ operator*=() [2/7]

Affine & Geom::Affine::operator*= ( HShear const &  h)

Combine this transformation with horizontal shearing (skew).

Definition at line 119 of file transforms.cpp.

References _c, and Geom::ShearBase< S >::f.

◆ operator*=() [3/7]

Affine & Geom::Affine::operator*= ( Rotate const &  r)

Combine this transformation a rotation.

Definition at line 111 of file transforms.cpp.

References Affine().

◆ operator*=() [4/7]

Affine & Geom::Affine::operator*= ( Scale const &  s)

Combine this transformation with scaling.

Definition at line 103 of file transforms.cpp.

References _c, Geom::X, and Geom::Y.

◆ operator*=() [5/7]

Affine & Geom::Affine::operator*= ( Translate const &  t)

Combine this transformation with a translation.

Definition at line 96 of file transforms.cpp.

References _c, Geom::X, and Geom::Y.

◆ operator*=() [6/7]

Affine & Geom::Affine::operator*= ( VShear const &  v)

Combine this transformation with vertical shearing (skew).

Definition at line 127 of file transforms.cpp.

References _c, and Geom::SL::v.

◆ operator*=() [7/7]

Affine & Geom::Affine::operator*= ( Zoom const &  z)

Definition at line 134 of file transforms.cpp.

References _c, Geom::Zoom::_scale, Geom::Zoom::_trans, Geom::X, and Geom::Y.

◆ operator==()

bool Geom::Affine::operator== ( Affine const &  o) const
inline

Definition at line 109 of file affine.h.

References _c.

◆ operator[]() [1/2]

Coord & Geom::Affine::operator[] ( unsigned  i)
inline

Definition at line 95 of file affine.h.

References _c.

◆ operator[]() [2/2]

Coord Geom::Affine::operator[] ( unsigned  i) const
inline

Access a coefficient by its index.

Definition at line 94 of file affine.h.

References _c.

◆ preservesAngles()

bool Geom::Affine::preservesAngles ( Coord  eps = EPSILON) const

Check whether the transformation preserves angles between lines.

This means that the transformation can be any combination of translation, uniform scaling, rotation and flipping.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a & b & 0 \\ -b & a & 0 \\ c & d & 1 \end{array}\right]\) or \(\left[\begin{array}{ccc} -a & b & 0 \\ b & a & 0 \\ c & d & 1 \end{array}\right]\).

Definition at line 339 of file affine.cpp.

References _c, are_near(), and isSingular().

Referenced by Inkscape::LivePathEffect::LPEMeasureSegments::doBeforeEffect(), and Geom::TEST().

◆ preservesArea()

bool Geom::Affine::preservesArea ( Coord  eps = EPSILON) const

Check whether the transformation preserves areas of polygons.

This means that the transformation can be any combination of translation, rotation, shearing and squeezing (non-uniform scaling such that the absolute value of the product of Y-scale and X-scale is 1).

Parameters
epsNumerical tolerance
Returns
True iff \(|\det A| = 1\).

Definition at line 321 of file affine.cpp.

References are_near(), and descrim2().

Referenced by Geom::TEST().

◆ preservesDistances()

bool Geom::Affine::preservesDistances ( Coord  eps = EPSILON) const

Check whether the transformation preserves distances between points.

This means that the transformation can be any combination of translation, rotation and flipping.

Parameters
epsNumerical tolerance
Returns
True iff the matrix is of the form \(\left[\begin{array}{ccc} a & b & 0 \\ -b & a & 0 \\ c & d & 1 \end{array}\right]\) or \(\left[\begin{array}{ccc} -a & b & 0 \\ b & a & 0 \\ c & d & 1 \end{array}\right]\) and \(a^2 + b^2 = 1\).

Definition at line 359 of file affine.cpp.

References _c, and are_near().

Referenced by Geom::TEST().

◆ rotationCenter()

Point Geom::Affine::rotationCenter ( ) const

For a (possibly non-pure) non-zero-rotation matrix, calculate the rotation center.

Precondition
The matrix must be a non-zero-rotation matrix to prevent division by zero, see isNonzeroNonpureRotation().
Returns
The rotation center x, the solution to the equation \(A x = x\).

Definition at line 243 of file affine.cpp.

References _c.

Referenced by Geom::TEST().

◆ setExpansionX()

void Geom::Affine::setExpansionX ( Coord  val)

Definition at line 75 of file affine.cpp.

References _c, and expansionX().

Referenced by Inkscape::UI::Tools::spdc_check_for_and_apply_waiting_LPE().

◆ setExpansionY()

void Geom::Affine::setExpansionY ( Coord  val)

Definition at line 85 of file affine.cpp.

References _c, and expansionY().

Referenced by Inkscape::UI::Tools::spdc_check_for_and_apply_waiting_LPE().

◆ setIdentity()

◆ setTranslation()

◆ setXAxis()

void Geom::Affine::setXAxis ( Point const &  vec)

Definition at line 45 of file affine.cpp.

References _c.

Referenced by Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), and wrap_transforms().

◆ setYAxis()

void Geom::Affine::setYAxis ( Point const &  vec)

Definition at line 50 of file affine.cpp.

References _c.

Referenced by Inkscape::LivePathEffect::LPECurveStitch::doEffect_path(), and wrap_transforms().

◆ translation()

Point Geom::Affine::translation ( ) const

Gets the translation imparted by the Affine.

Definition at line 41 of file affine.cpp.

References _c.

Referenced by SPMarker::get_marker_transform(), Inkscape::DrawingCache::prepare(), Inkscape::Text::Layout::show(), and wrap_transforms().

◆ withoutTranslation()

◆ xAxis()

◆ yAxis()

Point Geom::Affine::yAxis ( ) const

Friends And Related Function Documentation

◆ are_near()

bool are_near ( Affine const &  a,
Affine const &  b,
Coord  eps 
)
related

◆ elliptic_quadratic_form()

Affine elliptic_quadratic_form ( Affine const &  m)
related

Given a matrix m such that unit_circle = m*x, this returns the quadratic form x*A*x = 1.

Definition at line 461 of file affine.cpp.

References Hsluv::m.

◆ identity()

Affine identity ( )
related

Create an identity matrix.

Returns
The matrix \(\left[\begin{array}{ccc} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array}\right]\).

Definition at line 222 of file affine.h.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out_file,
const Geom::Affine m 
)
related

Print out the Affine (for debugging).

Definition at line 188 of file affine.h.

References Hsluv::m.

Member Data Documentation

◆ _c


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