36#ifndef LIB2GEOM_SEEN_TRANSFORMS_H
37#define LIB2GEOM_SEEN_TRANSFORMS_H
43#include <boost/concept/assert.hpp>
79 : boost::equality_comparable< T
80 , boost::multipliable< T
84 template <
typename T2>
86 Affine ret(*
static_cast<T const*
>(
this)); ret *= t;
return ret;
98T
pow(T
const &t,
int n) {
100 if (n == 0)
return T::identity();
102 T x(n < 0 ? t.inverse() : t);
105 if ( n & 1 ) {
result *= x; --n; }
242 S &
operator*=(S
const &s) {
f += s.f;
return static_cast<S &
>(*this); }
337 return Scale(::pow(s[
X], n), ::pow(s[
Y], n));
3x3 affine transformation matrix.
Various trigoniometric helper functions.
3x3 matrix representing an affine transformation.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Rotation around the origin.
Rotate & operator*=(Rotate const &o)
static Affine around(Point const &p, Coord angle)
Coord operator[](unsigned dim) const
static Rotate from_degrees(Coord deg)
Construct a rotation from its angle in degrees.
Rotate(Coord theta)
Construct a rotation from its angle in radians.
Rotate(Point const &p)
Construct a rotation from its characteristic vector.
static Rotate identity()
Get a zero-degree rotation.
bool operator==(Rotate const &o) const
Rotate(Coord x, Coord y)
Construct a rotation from the coordinates of its characteristic vector.
Coord operator[](Dim2 dim) const
Point const & vector() const
Get the characteristic vector of the rotation.
Rotate()=default
Construct a zero-degree rotation.
Scale()=default
Create a scaling that doesn't do anything.
Scale & operator*=(Scale const &b)
Scale(Coord s)
Create an uniform scaling from a single scaling factor.
Coord operator[](Dim2 d) const
Scale(Coord x, Coord y)
Create a scaling from two scaling factors.
Coord operator[](unsigned d) const
Scale pow(Scale const &s, int n)
Specialization of exponentiation for Scale.
Scale(Point const &p)
Create a scaling from two scaling factors given as coordinates of a point.
Coord & operator[](unsigned d)
bool operator==(Scale const &o) const
Coord & operator[](Dim2 d)
Common base for shearing transforms.
bool operator==(ShearBase< S > const &s) const
S & operator*=(S const &s)
bool operator==(Translate const &o) const
Translate pow(Translate const &t, int n)
Specialization of exponentiation for Translate.
static Translate identity()
Get a translation that doesn't do anything.
Translate(Coord x, Coord y)
Construct a translation from its coordinates.
Translate()=default
Create a translation that doesn't do anything.
Coord operator[](unsigned dim) const
Translate(Point const &p)
Construct a translation from its vector.
Translate inverse() const
Get the inverse translation.
Translate & operator*=(Translate const &o)
Coord operator[](Dim2 dim) const
Combination of a translation and uniform scale.
Zoom(Coord s, Point const &t)
Construct a zoom from a scaling factor and a translation.
Zoom(Coord s, Translate const &t)
Zoom(Point const &t)
Construct a zoom from a translation.
bool operator==(Zoom const &z) const
void setTranslation(Point const &p)
static Zoom map_rect(Rect const &old_r, Rect const &new_r)
Zoom between rectangles.
Point translation() const
Zoom(Coord s)
Construct a zoom from a scaling factor.
Zoom & operator*=(Zoom const &z)
Contains forward declarations of 2geom types.
Dim2
2D axis enumeration (X or Y).
double Coord
Floating point type used to store coordinates.
constexpr Coord EPSILON
Default "acceptably small" value.
Various utility functions.
double atan2(Point const &p)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)