37    return projected != aSeg.
A && projected != aSeg.
B;
 
 
   43    const double length = aSeg.
Length();
 
   44    const double projected_length = ( aPoint - aSeg.
A ).EuclideanNorm();
 
   45    return projected_length / length;
 
 
   53    if( projected == aSeg.
A )
 
   55    if( projected == aSeg.
B )
 
 
   64    const double distToCBStart = aSeg.
A.
Distance( aPoint );
 
   65    const double distToCBEnd = aSeg.
B.
Distance( aPoint );
 
   66    return ( distToCBStart <= distToCBEnd ) ? aSeg.
A : aSeg.
B;
 
 
   72    return ( x + ( x < 0 ? -g / 2 : g / 2 ) ) / g * g;
 
 
   78    return ( ( x < 0 ? ( x - g + 1 ) : x ) / g ) * g;
 
 
   84    return ( ( x < 0 ? x : ( x + g - 1 ) ) / g ) * g;
 
 
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
 
int Length() const
Return the length (this).
 
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
 
bool PointProjectsOntoSegment(const VECTOR2I &aPoint, const SEG &aSeg)
Determine if a point projects onto a segment.
 
double GetLengthRatioFromStart(const VECTOR2I &aPoint, const SEG &aSeg)
Get the ratio of the vector to a point from the segment's start, compared to the segment's length.
 
bool SegIsInDirection(const SEG &aSeg, const VECTOR2I &aDirection)
Determine if a segment's vector is within 90 degrees of a given direction.
 
VECTOR2I RoundNW(const VECTOR2I &aVec, int aGridSize)
Round a vector to the nearest grid point in the NW direction.
 
VECTOR2I RoundSE(const VECTOR2I &aVec, int aGridSize)
Round a vector to the nearest grid point in the SE direction.
 
const VECTOR2I & GetNearestEndpoint(const SEG &aSeg, const VECTOR2I &aPoint)
Get the nearest end of a segment to a point.
 
double GetProjectedPointLengthRatio(const VECTOR2I &aPoint, const SEG &aSeg)
Get the ratio of the vector to a point projected onto a segment from the start, relative to the segme...
 
VECTOR2I RoundGrid(const VECTOR2I &aVec, int aGridSize)
Round a vector to the nearest grid point in any direction.
 
bool PointIsInDirection(const VECTOR2< T > &aPoint, const VECTOR2< T > &aDirection, const VECTOR2< T > &aFrom)
 
VECTOR2< int32_t > VECTOR2I
 
static constexpr T RoundDown(T x, T g)
 
static constexpr T RoundUp(T x, T g)
 
static constexpr T RoundNearest(T x, T g)
 
Supplemental functions for working with vectors and simple objects that interact with vectors.