20inline bool unit_rect_contains(
Point const &p)
22 return 0 <= p.x() && p.x() <= 1 &&
23 0 <= p.y() && p.y() <= 1;
27inline Point unit_rect_corner(
unsigned i)
30 unsigned const y = i >> 1;
31 unsigned const x = (i & 1) ^ y;
39 return unit_rect_corner(i) *
m_affine;
57 auto const affine2 = affine1.
inverse();
60 for (
unsigned i = 0; i != 4; ++i) {
61 auto const p = unit_rect_corner(i);
62 if (unit_rect_contains(p * affine1) ||
63 unit_rect_contains(p * affine2)) {
69 for (
unsigned i = 0; i != 2; ++i) {
71 auto const B =
corner((i + 2) % 4);
72 for (
unsigned j = 0; j != 2; ++j) {
73 auto const C = other.
corner(j);
74 auto const D = other.
corner((j + 2) % 4);
98 for (
unsigned i = 0; i != 4; ++i) {
99 if (!unit_rect_contains(other.
corner(i) * inv)) {
pair< double, double > Point
Basic intersection routines.
Coord expansionX() const
Calculates the amount of x-scaling imparted by the Affine.
bool isSingular(Coord eps=EPSILON) const
Check whether this matrix is singular.
Affine inverse() const
Compute the inverse matrix.
Coord expansionY() const
Calculates the amount of y-scaling imparted by the Affine.
void expandTo(CPoint const &p)
Enlarge the rectangle to contain the given point.
Paralellogram, representing a linear transformation of a rectangle.
bool isSheared(Coord eps=EPSILON) const
True if this parallelogram does not have right angles.
Rect bounds() const
Axis-aligned bounding box.
Point corner(unsigned i) const
bool contains(Point const &) const
Coord maxExtent() const
Returns longer side length.
bool intersects(Parallelogram const &) const
Coord minExtent() const
Returns shorter side length.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
double Coord
Floating point type used to store coordinates.
Various utility functions.
bool non_collinear_segments_intersect(const Point &A, const Point &B, const Point &C, const Point &D)
Check if two line segments intersect.
T dot(D2< T > const &a, D2< T > const &b)
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)