18 #include "precompiled.h"
24 using namespace Geometry;
31 if (-halfSize.
X <= du && du <= halfSize.
X)
34 if (-halfSize.
Y <= dv && dv <= halfSize.
Y)
50 return acosf(1.f -
SQR(chordLength)/(2.f*
SQR(radius)));
90 if (-hw < du && du < hw)
94 if (-hh < dv && dv < hh)
95 closest = std::min(closest, (du.
Absolute() - hw).Absolute());
99 else if (-hh < dv && dv < hh)
101 return (du.
Absolute() - hw).Absolute();
115 return (corner - point).
Length();
153 if (-hw < du && du < hw)
155 if (-hh < dv && dv < hh && (du.
Absolute() - hw).Absolute() < (dv.
Absolute() - hh).Absolute())
170 else if (-hh < dv && dv < hh)
214 if (-hw <= au && au <= hw && -hh <= av && av <= hh)
220 if (-hw <= bu && bu <= hw && -hh <= bv && bv <= hh)
223 if ((au < -hw && bu < -hw) || (au > hw && bu > hw) || (av < -hh && bv < -hh) || (av > hh && bv > hh))
256 if (-hw <= au && au <= hw && -hh <= av && av <= hh)
262 if (-hw <= bu && bu <= hw && -hh <= bv && bv <= hh)
265 if ((au < -hw && bu < -hw) || (au > hw && bu > hw) || (av < -hh && bv < -hh) || (av > hh && bv > hh))
317 if (!
SquareSAT(corner0a - c1, -u0, u1, v1, halfSize1))
319 if (!
SquareSAT(corner0a - c1, v0, u1, v1, halfSize1))
321 if (!
SquareSAT(corner0b - c1, u0, u1, v1, halfSize1))
323 if (!
SquareSAT(corner0b - c1, -v0, u1, v1, halfSize1))
325 if (!
SquareSAT(corner1a - c0, -u1, u0, v0, halfSize0))
327 if (!
SquareSAT(corner1a - c0, v1, u0, v0, halfSize0))
329 if (!
SquareSAT(corner1b - c0, u1, u0, v0, halfSize0))
331 if (!
SquareSAT(corner1b - c0, -v1, u0, v0, halfSize0))
A simple fixed-point number class.
fixed Dot(const CFixedVector2D &v)
Compute the dot product of this vector with another.
CFixedVector2D NearestPointOnSquare(CFixedVector2D point, CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)
Find point closest to the given point on the edge of the given square or rectangle.
CFixedVector2D Perpendicular()
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
static bool SquareSAT(CFixedVector2D a, CFixedVector2D axis, CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)
Separating axis test; returns true if the square defined by u/v/halfSize at the origin is not entirel...
bool TestRayAASquare(CFixedVector2D a, CFixedVector2D b, CFixedVector2D halfSize)
bool TestRaySquare(CFixedVector2D a, CFixedVector2D b, CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)
static CFixed FromInt(int n)
CFixedVector2D Multiply(fixed n) const
Multiply by a CFixed.
bool TestSquareSquare(CFixedVector2D c0, CFixedVector2D u0, CFixedVector2D v0, CFixedVector2D halfSize0, CFixedVector2D c1, CFixedVector2D u1, CFixedVector2D v1, CFixedVector2D halfSize1)
fixed Length() const
Returns the length of the vector.
bool IsZero() const
Returns true if the number is precisely 0.
fixed DistanceToSquare(CFixedVector2D point, CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)
float ChordToCentralAngle(const float chordLength, const float radius)
Given a circle of radius radius, and a chord of length chordLength on this circle, computes the central angle formed by connecting the chord's endpoints to the center of the circle.
bool PointIsInSquare(CFixedVector2D point, CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)
Checks if a point is inside the given rotated square or rectangle.
Helper functions related to geometry algorithms.
CFixedVector2D GetHalfBoundingBox(CFixedVector2D u, CFixedVector2D v, CFixedVector2D halfSize)