BEEP-8 Helper Lib 1.0.0
Loading...
Searching...
No Matches
Vec Class Reference

Public Member Functions

 Vec (fx8 x_=0, fx8 y_=0)
 
Vecset (fx8 x_=0, fx8 y_=0)
 
Vecadd (fx8 x_=0, fx8 y_=0)
 
Vecsub (fx8 x_=0, fx8 y_=0)
 
Vecmul (fx8 v)
 
Vecdiv (fx8 v)
 
Vecclamp (fx8 xLow, fx8 xHigh, fx8 yLow, fx8 yHigh)
 
Vecwrap (fx8 xLow, fx8 xHigh, fx8 yLow, fx8 yHigh)
 
VecsetWithAngle (fx8 angle, fx8 length)
 
VecaddWithAngle (fx8 angle, fx8 length)
 
VecswapXy ()
 
Vecnormalize ()
 
Vecrotate (fx8 angle)
 
fx8 angleTo (fx8 x_, fx8 y_) const
 
fx8 distanceTo (fx8 x_, fx8 y_) const
 
fx8 distanceTo (const Vec &xy_) const
 
bool isInRect (fx8 x_, fx8 y_, fx8 width, fx8 height) const
 
bool isInRect (const Rect &rc) const
 
bool equals (const Vec &other) const
 
Vecfloor ()
 
Vecround ()
 
Vecceil ()
 
fx8 length () const
 
fx8 angle () const
 
Vecnegative ()
 
Vec operator+ (const Vec &other) const
 
Vec operator- (const Vec &other) const
 
Vecoperator+= (const Vec &other)
 
Vecoperator-= (const Vec &other)
 
Vec operator* (fx8 scalar) const
 
Vecoperator*= (fx8 scalar)
 
Vec operator* (const Vec &other) const
 
Vecoperator*= (const Vec &other)
 
Vec operator/ (const Vec &other) const
 
Vecoperator/= (const Vec &other)
 
Vec operator/ (fx8 scalar) const
 
Vecoperator/= (fx8 scalar)
 
VecclampLength (fx8 maxLength)
 Clamps the length of the vector to the specified maximum value.
 

Public Attributes

fx8 x
 
fx8 y
 

Member Function Documentation

◆ clampLength()

Vec & Vec::clampLength ( fx8 maxLength)
inline

Clamps the length of the vector to the specified maximum value.

If the current length of the vector exceeds the specified maxLength, the vector's components are scaled down proportionally to match maxLength. If the current length is less than or equal to maxLength, no changes are made.

Parameters
maxLengthThe maximum allowable length for the vector. Must be a non-negative value.
Returns
A reference to the modified vector.
Note
If the current length of the vector is zero, no scaling is performed.

The documentation for this class was generated from the following files: