27 return Affine(x_basis[
X], x_basis[
Y],
28 y_basis[
X], y_basis[
Y],
46 for(
int i = 0; i < 2; i++)
51 for(
int i = 0; i < 2; i++)
57 for(
int i = 0; i < 2; i++)
79 for (
unsigned i = 0; i < 2; ++i) {
89 for (
unsigned i = 2; i < 4; ++i) {
97 _c[0] = 1.0;
_c[1] = 0.0;
98 _c[2] = 0.0;
_c[3] = 1.0;
99 _c[4] = 0.0;
_c[5] = 0.0;
391 double mx = std::max(fabs(
_c[0]) + fabs(
_c[1]),
392 fabs(
_c[2]) + fabs(
_c[3]));
398 d.
_c[0] =
_c[3] * ideterm;
399 d.
_c[1] = -
_c[1] * ideterm;
400 d.
_c[2] = -
_c[2] * ideterm;
401 d.
_c[3] =
_c[0] * ideterm;
402 d.
_c[4] = (-
_c[4] * d.
_c[0] -
_c[5] * d.
_c[2]);
403 d.
_c[5] = (-
_c[4] * d.
_c[1] -
_c[5] * d.
_c[3]);
418 return _c[0] *
_c[3] -
_c[1] *
_c[2];
444 for(
int a = 0; a < 5; a += 2) {
445 for(
int b = 0; b < 2; b++) {
446 nc[a + b] =
_c[a] * o.
_c[b] +
_c[a + 1] * o.
_c[b + 2];
449 for(
int a = 0; a < 6; ++a) {
462 double od = m[0] * m[1] + m[2] * m[3];
463 Affine ret (m[0]*m[0] + m[1]*m[1], od,
464 od, m[2]*m[2] + m[3]*m[3],
470 double const B = -m[0] - m[3];
471 double const C = m[0]*m[3] - m[1]*m[2];
475 for (
unsigned i = 0; i < v.size(); ++i) {
479 for (
unsigned i = v.size(); i < 2; ++i) {
486 double const B = -m[0][0] - m[1][1];
487 double const C = m[0][0]*m[1][1] - m[1][0]*m[0][1];
491 for (
unsigned i = 0; i < v.size(); ++i) {
495 for (
unsigned i = v.size(); i < 2; ++i) {
Cartesian point / 2D vector and related operations.
Various utility functions.
3x3 affine transformation matrix.
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.
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 are_near(Affine const &a, Affine const &b, Coord eps)
Nearness predicate for affine transforms.
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.
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.
bool isNonzeroUniformScale(Coord eps=EPSILON) const
Check whether this matrix represents pure, nonzero uniform scaling.
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)
bool isRotation(Coord eps=EPSILON) const
Check whether this matrix represents a pure rotation.
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.
Two-dimensional point that doubles as a vector.
double Coord
Floating point type used to store coordinates.
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.
bool rel_error_bound(Coord a, Coord b, double eps=EPSILON)
std::vector< Coord > solve_quadratic(Coord a, Coord b, Coord c)
Analytically solve quadratic equation.
SBasisN< n > sqrt(SBasisN< n > const &a, int k)
Point unit_vector(Point const &a)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
D2< T > rot90(D2< T > const &a)
Polynomial in canonical (monomial) basis.