Roboid Control for C#
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
LinearAlgebra.Angle Class Reference

Detailed Description

Angle utilities

Static Public Member Functions

static float Clamp (float angle, float min, float max)
 Clamp the angle between the given min and max values.
 
static float Difference (float a, float b)
 Determine the angle difference, result is a normalized angle.
 
static float Normalize (float angle)
 Normalize an angle to the range -180 < angle <= 180.
 
static float MoveTowards (float fromAngle, float toAngle, float maxAngle)
 Rotate from one angle to the other with a maximum degrees.
 
static float ToFactor (Vector2 v1, Vector2 v2)
 Map interval of angles between vectors [0..Pi] to interval [0..1].
 

Static Public Attributes

const float pi = 3.1415927410125732421875F
 
const float Deg2Rad = 360.0f / ((float)Math.PI * 2)
 
const float Rad2Deg = ((float)Math.PI * 2) / 360.0f
 

Member Function Documentation

◆ Clamp()

static float LinearAlgebra.Angle.Clamp ( float  angle,
float  min,
float  max 
)
static

Clamp the angle between the given min and max values.

Parameters
angleThe angle to clamp
minThe minimum angle
maxThe maximum angle
Returns
The clamped angle

Angles are normalized

◆ Difference()

static float LinearAlgebra.Angle.Difference ( float  a,
float  b 
)
static

Determine the angle difference, result is a normalized angle.

Parameters
aFirst first angle
bThe second angle
Returns
the angle between the two angles

Angle values should be degrees

◆ Normalize()

static float LinearAlgebra.Angle.Normalize ( float  angle)
static

Normalize an angle to the range -180 < angle <= 180.

Parameters
angleThe angle to normalize
Returns
The normalized angle in interval (-180..180]

Angle values should be in degrees

◆ MoveTowards()

static float LinearAlgebra.Angle.MoveTowards ( float  fromAngle,
float  toAngle,
float  maxAngle 
)
static

Rotate from one angle to the other with a maximum degrees.

Parameters
fromAngleStarting angle
toAngleTarget angle
maxAngleMaximum angle to rotate
Returns
The resulting angle

This function is compatible with radian and degrees angles

◆ ToFactor()

static float LinearAlgebra.Angle.ToFactor ( Vector2  v1,
Vector2  v2 
)
static

Map interval of angles between vectors [0..Pi] to interval [0..1].

Parameters
v1The first vector
v2The second vector
Returns
The resulting factor in interval [0..1]

Vectors a and b must be normalized

Deprecated:
Please use Vector2.ToFactor instead.