Math Extensions

Lerp Angle

This linearly interpolates between two angles, ensuring the shortest path is taken.

float angleA = 30f;
float angleB = 350f;

float lerp = MathExtensions.LerpAngle(angleA, angleB, 0.5f);

Smooth Step

This smoothly interpolates between two values using Hermite interpolation.

float start = 0f;
float end = 1f;

float smooth = MathExtensions.SmoothStep(start, end, 0.5f);

Sinerp

This smoothly interpolates between two values using sine interpolation.

float valueA = 0f;
float valueB = 10f;

float sinerp = MathExtensions.Sinerp(valueA, valueB, 0.5f);

Round To Nearest

This rounds a number to the nearest specified increment.

Shortest Difference

This calculates the shortest difference between two angles.

Average

This calculates the average of an array of floats.

Max

This retrieves the maximum value from an array of floats.

Min

This retrieves the minimum value from an array of floats.

Sum

This calculates the sum of an array of floats.

Last updated