stc
Loading...
Searching...
No Matches
Functions
stc::math::g2d Namespace Reference

Functions

template<typename IT , VectorType2D< IT > VT>
bool isCounterClockwise (const VT &a, const VT &b, const VT &c)
 
template<SignedNumber IT, VectorType2D< IT > VT>
IT isPointOnLeftOfEdge (const VT &point, const VT &lineStart, const VT &lineEnd)
 
template<typename IT , VectorType2D< IT > VT>
requires std::equality_comparable_with<VT, VT>
bool lineIntersectsLineInclusive (const VT &l1Start, const VT &l1End, const VT &l2Start, const VT &l2End)
 
template<typename IT , VectorType2D< IT > VT>
bool lineIntersectsRectangleInclusive (const VT &lineStart, const VT &lineEnd, const VT &rectCornerA, const VT &rectCornerB, const VT &rectCornerC, const VT &rectCornerD)
 
template<SignedNumber IT, VectorType2D< IT > VT>
bool rectangleContainsPointExclusive (const VT &point, const VT &rectCornerA, const VT &rectCornerB, const VT &rectCornerC, const VT &rectCornerD)
 
template<SignedNumber IT, VectorType2D< IT > VT>
bool rectangleContainsPointInclusive (const VT &point, const VT &rectCornerA, const VT &rectCornerB, const VT &rectCornerC, const VT &rectCornerD)
 
template<typename IT , VectorType2D< IT > VT>
bool rectangleContainsPointInclusive (const VT &point, const VT &startPosition, const VT &endPosition)
 
template<SignedNumber IT, VectorType2D< IT > VT>
bool lineIntersectsRectangleInclusive (const VT &lineStart, const VT &lineEnd, const VT &rectStart, const VT &rectEnd)
 
template<SignedNumber IT, VectorType2D< IT > VT>
bool lineIntersectsRectangleExclusive (const VT &lineStart, const VT &lineEnd, const VT &rectStart, const VT &rectEnd)
 

Detailed Description

Contains 2D geometric utility functions.

For 3D, when it eventually is implemented, see the g3d namespace.

Function Documentation

◆ isCounterClockwise()

template<typename IT , VectorType2D< IT > VT>
bool stc::math::g2d::isCounterClockwise ( const VT &  a,
const VT &  b,
const VT &  c 
)
inline

Primarily an internal helper function. Checks if three provided points are counter-clockwise.

◆ isPointOnLeftOfEdge()

template<SignedNumber IT, VectorType2D< IT > VT>
IT stc::math::g2d::isPointOnLeftOfEdge ( const VT &  point,
const VT &  lineStart,
const VT &  lineEnd 
)
inline

Returns whether or not a point is on the left of an edge

Returns
> 0 if on the left, 0 if on the edge, < 0 if on the right. This is based on the direction of the vector, so be careful when using in other functions

◆ lineIntersectsLineInclusive()

template<typename IT , VectorType2D< IT > VT>
requires std::equality_comparable_with<VT, VT>
bool stc::math::g2d::lineIntersectsLineInclusive ( const VT &  l1Start,
const VT &  l1End,
const VT &  l2Start,
const VT &  l2End 
)
inline

◆ lineIntersectsRectangleExclusive()

template<SignedNumber IT, VectorType2D< IT > VT>
bool stc::math::g2d::lineIntersectsRectangleExclusive ( const VT &  lineStart,
const VT &  lineEnd,
const VT &  rectStart,
const VT &  rectEnd 
)
inline

Checks if an axis-aligned rectangle is intersected by a line. The input assumes a rectangle defined by two opposing corners.

This function is inclusive, and includes points on the border.

◆ lineIntersectsRectangleInclusive() [1/2]

template<typename IT , VectorType2D< IT > VT>
bool stc::math::g2d::lineIntersectsRectangleInclusive ( const VT &  lineStart,
const VT &  lineEnd,
const VT &  rectCornerA,
const VT &  rectCornerB,
const VT &  rectCornerC,
const VT &  rectCornerD 
)
inline

Checks if a line intersects a rectangle.

Note that the input arguments are in the form

(B) #------# (C)
| |
(A) #------# (D)

This function is inclusive, meaning tangential lines (including lines on the borders) are considered an intersection. For tangential lines not to be included, use stc::math::g2d::lineIntersectsRectangleExclusive.

Nether of the functions check if the line is contained within the rectangle. Use stc::math::g2d::rectangleContainsPointExclusive and stc::math::g2d::rectangleContainsPointInclusive to check point inclusion.

◆ lineIntersectsRectangleInclusive() [2/2]

template<SignedNumber IT, VectorType2D< IT > VT>
bool stc::math::g2d::lineIntersectsRectangleInclusive ( const VT &  lineStart,
const VT &  lineEnd,
const VT &  rectStart,
const VT &  rectEnd 
)
inline

Checks if an axis-aligned rectangle is intersected by a line. The input assumes a rectangle defined by two opposing corners.

This function is inclusive, and includes points on the border.

◆ rectangleContainsPointExclusive()

template<SignedNumber IT, VectorType2D< IT > VT>
bool stc::math::g2d::rectangleContainsPointExclusive ( const VT &  point,
const VT &  rectCornerA,
const VT &  rectCornerB,
const VT &  rectCornerC,
const VT &  rectCornerD 
)
inline

Checks whether or not a rectangle contains a given point.

Note that the input arguments are in the form

(B) #------# (C)
| |
(A) #------# (D)

Also note that there's no requirement each corner is in that exact position.

This is an exclusive function, so points on the border are not included.

◆ rectangleContainsPointInclusive() [1/2]

template<SignedNumber IT, VectorType2D< IT > VT>
bool stc::math::g2d::rectangleContainsPointInclusive ( const VT &  point,
const VT &  rectCornerA,
const VT &  rectCornerB,
const VT &  rectCornerC,
const VT &  rectCornerD 
)
inline

Checks whether or not a rectangle contains a given point.

Note that the input arguments are in the form

(B) #------# (C)
| |
(A) #------# (D)

Also note that there's no requirement each corner is in that exact position.

This is an inclusive function, so points on the border are included.

◆ rectangleContainsPointInclusive() [2/2]

template<typename IT , VectorType2D< IT > VT>
bool stc::math::g2d::rectangleContainsPointInclusive ( const VT &  point,
const VT &  startPosition,
const VT &  endPosition 
)
inline

Checks if an axis-aligned rectangle contains a provided point. The input assumes a rectangle defined by two opposing corners.

This function is inclusive, and includes points on the border.