Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/helpers/Geometry.cpp
Show All 25 Lines | |||||
CFixedVector2D Geometry::GetHalfBoundingBox(const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize) | CFixedVector2D Geometry::GetHalfBoundingBox(const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize) | ||||
{ | { | ||||
return CFixedVector2D( | return CFixedVector2D( | ||||
u.X.Multiply(halfSize.X).Absolute() + v.X.Multiply(halfSize.Y).Absolute(), | u.X.Multiply(halfSize.X).Absolute() + v.X.Multiply(halfSize.Y).Absolute(), | ||||
u.Y.Multiply(halfSize.X).Absolute() + v.Y.Multiply(halfSize.Y).Absolute() | u.Y.Multiply(halfSize.X).Absolute() + v.Y.Multiply(halfSize.Y).Absolute() | ||||
); | ); | ||||
} | } | ||||
float Geometry::ChordToCentralAngle(const float chordLength, const float radius) | |||||
{ | |||||
return acosf(1.f - SQR(chordLength)/(2.f*SQR(radius))); // cfr. law of cosines | |||||
} | |||||
fixed Geometry::DistanceToSquare(const CFixedVector2D& point, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize, bool countInsideAsZero) | fixed Geometry::DistanceToSquare(const CFixedVector2D& point, const CFixedVector2D& u, const CFixedVector2D& v, const CFixedVector2D& halfSize, bool countInsideAsZero) | ||||
{ | { | ||||
/* | /* | ||||
* Relative to its own coordinate system, we have a square like: | * Relative to its own coordinate system, we have a square like: | ||||
* | * | ||||
* A : B : C | * A : B : C | ||||
* : : | * : : | ||||
* - - ########### - - | * - - ########### - - | ||||
▲ Show 20 Lines • Show All 278 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator