14#ifndef LIB2GEOM_SEEN_AFFINE_H
15#define LIB2GEOM_SEEN_AFFINE_H
17#include <boost/operators.hpp>
61 : boost::equality_comparable< Affine
62 , boost::multipliable1< Affine
63 , MultipliableNoncommutative< Affine, Translate
64 , MultipliableNoncommutative< Affine, Scale
65 , MultipliableNoncommutative< Affine, Rotate
66 , MultipliableNoncommutative< Affine, HShear
67 , MultipliableNoncommutative< Affine, VShear
68 , MultipliableNoncommutative< Affine, Zoom
88 _c[0] = c0;
_c[1] = c1;
89 _c[2] = c2;
_c[3] = c3;
90 _c[4] = c4;
_c[5] = c5;
110 for(
unsigned i = 0; i < 6; ++i) {
111 if (
_c[i] != o.
_c[i] )
return false;
188inline std::ostream &operator<< (std::ostream &out_file,
const Geom::Affine &m) {
189 out_file <<
"A: " << m[0] <<
" C: " << m[2] <<
" E: " << m[4] <<
"\n";
190 out_file <<
"B: " << m[1] <<
" D: " << m[3] <<
" F: " << m[5] <<
"\n";
205 Eigen(
double M[2][2]);
Cartesian point / 2D vector and related operations.
Various utility functions.
3x3 matrix representing an affine transformation.
void setYAxis(Point const &vec)
bool isHShear(Coord eps=EPSILON) const
Check whether this matrix represents pure horizontal shearing.
bool isNonzeroScale(Coord eps=EPSILON) const
Check whether this matrix represents pure, nonzero scaling.
Coord det() const
Calculate the determinant.
void setTranslation(Point const &loc)
Sets the translation imparted by the Affine.
bool flips() const
Check whether this transformation flips objects.
Coord operator[](unsigned i) const
Access a coefficient by its index.
bool preservesDistances(Coord eps=EPSILON) const
Check whether the transformation preserves distances between points.
bool preservesAngles(Coord eps=EPSILON) const
Check whether the transformation preserves angles between lines.
bool preservesArea(Coord eps=EPSILON) const
Check whether the transformation preserves areas of polygons.
Point translation() const
Gets the translation imparted by the Affine.
Coord descrim() const
Calculate the descriminant.
bool isNonzeroNonpureRotation(Coord eps=EPSILON) const
Check whether this matrix represents a non-zero rotation about any point.
bool isScale(Coord eps=EPSILON) const
Check whether this matrix represents pure scaling.
bool isUniformScale(Coord eps=EPSILON) const
Check whether this matrix represents pure uniform scaling.
void setXAxis(Point const &vec)
bool isNonzeroTranslation(Coord eps=EPSILON) const
Check whether this matrix represents a pure nonzero translation.
Coord expansionX() const
Calculates the amount of x-scaling imparted by the Affine.
bool isNonzeroHShear(Coord eps=EPSILON) const
Check whether this matrix represents pure, nonzero horizontal shearing.
void setExpansionX(Coord val)
Coord descrim2() const
Calculate the square of the descriminant.
bool isVShear(Coord eps=EPSILON) const
Check whether this matrix represents pure vertical shearing.
bool isSingular(Coord eps=EPSILON) const
Check whether this matrix is singular.
bool isZoom(Coord eps=EPSILON) const
Check whether this matrix represents zooming.
bool isIdentity(Coord eps=EPSILON) const
Check whether this matrix is an identity matrix.
bool isNonzeroUniformScale(Coord eps=EPSILON) const
Check whether this matrix represents pure, nonzero uniform scaling.
Coord & operator[](unsigned i)
Point rotationCenter() const
For a (possibly non-pure) non-zero-rotation matrix, calculate the rotation center.
void setIdentity()
Sets this matrix to be the Identity Affine.
bool isNonzeroVShear(Coord eps=EPSILON) const
Check whether this matrix represents pure, nonzero vertical shearing.
bool isTranslation(Coord eps=EPSILON) const
Check whether this matrix represents a pure translation.
Affine inverse() const
Compute the inverse matrix.
Affine & operator*=(Affine const &m)
Combine this transformation with another one.
void setExpansionY(Coord val)
Affine withoutTranslation() const
bool isRotation(Coord eps=EPSILON) const
Check whether this matrix represents a pure rotation.
bool operator==(Affine const &o) const
bool isNonzeroRotation(Coord eps=EPSILON) const
Check whether this matrix represents a pure, nonzero rotation.
Coord expansionY() const
Calculates the amount of y-scaling imparted by the Affine.
Affine(Coord c0, Coord c1, Coord c2, Coord c3, Coord c4, Coord c5)
Create a matrix from its coefficient values.
Given a matrix (ignoring the translation) this returns the eigen values and vectors.
Two-dimensional point that doubles as a vector.
Rotation around the origin.
Combination of a translation and uniform scale.
Contains forward declarations of 2geom types.
double Coord
Floating point type used to store coordinates.
constexpr Coord EPSILON
Default "acceptably small" value.
Various utility functions.
Affine from_basis(const Point &x_basis, const Point &y_basis, const Point &offset=Point(0, 0))
Creates a Affine given an axis and origin point.
Affine identity()
Create an identity matrix.
Affine elliptic_quadratic_form(Affine const &m)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)