Class MathsLibrary
- Namespace
- NominalSystems.Maths
- Assembly
- NominalSystems.Maths.dll
[Nominal] A library of mathematical functions that can be used by components and testing functions.
public static class MathsLibrary
- Inheritance
-
MathsLibrary
Methods
AcosTest(double, double, double)
Calculates an angle using an 'Acos' operation and then perform a quadrant check. This will return zero if the adjacent is equal to the hypotenuse.
public static double AcosTest(double adjacent, double hypotenuse, double test)
Parameters
adjacent
double[-] The length of the adjacent
hypotenuse
double[-] The length of the hypotenuse
test
double[rad] The test angle
Returns
- double
The value of the Acos function with safety
CubicInterpolate(Vector2, Vector2, Vector2, Vector2, double)
Cubic interpolation between 4 vectors
public static Vector2 CubicInterpolate(Vector2 a, Vector2 b, Vector2 c, Vector2 d, double t)
Parameters
a
Vector21st vector
b
Vector22nd vector
c
Vector23rd vector
d
Vector24th vector
t
doublea delta time
Returns
- Vector2
a interpolated vector
CubicInterpolate(Vector3, Vector3, Vector3, Vector3, double)
Cubic interpolation between 4 vectors
public static Vector3 CubicInterpolate(Vector3 a, Vector3 b, Vector3 c, Vector3 d, double t)
Parameters
a
Vector31st vector
b
Vector32nd vector
c
Vector33rd vector
d
Vector34th vector
t
doublea delta time
Returns
- Vector3
a interpolated vector
CubicInterpolate(double, double, double, double, double)
Cubic interpolation between 4 doubles
public static double CubicInterpolate(double a, double b, double c, double d, double t)
Parameters
a
double1st double
b
double2nd double
c
double3rd double
d
double4th double
t
doubleA delta time
Returns
- double
An interpolated double
LinearInterpolate(Vector2, Vector2, double)
Linear interpolation between 2 vectors
public static Vector2 LinearInterpolate(Vector2 a, Vector2 b, double t)
Parameters
Returns
- Vector2
An interpolated vector
LinearInterpolate(Vector3, Vector3, double)
Linear interpolation between 2 vectors
public static Vector3 LinearInterpolate(Vector3 a, Vector3 b, double t)
Parameters
Returns
- Vector3
a interpolated vector
LinearInterpolate(Vector4, Vector4, double)
Linearly interpolates between two quaternions, which are in the form of a Vector4 (X, Y, Z, W) and some alpha parameter that is assumed to be between 0 and 1.
public static Vector4 LinearInterpolate(Vector4 q1, Vector4 q2, double alpha)
Parameters
q1
Vector4[-] The 'from' quaternion
q2
Vector4[-] The 'to' quaternion
alpha
double[-] The scaling factor between 0 and 1
Returns
- Vector4
[-] The quaternion that is interpolated between the two
LinearInterpolate(Vector4, Vector4, double, double, double)
Linearly interpolates between two quaternions, which are in the form of a Vector4 (X, Y, Z, W) and some time varying parameters from the first time to the second time.
public static Vector4 LinearInterpolate(Vector4 q1, Vector4 q2, double t1, double t2, double t)
Parameters
q1
Vector4[-] The 'from' quaternion
q2
Vector4[-] The 'to' quaternion
t1
double[-] The first time that the 'from' quaternion exists at
t2
double[-] The second time that the 'to' quaternion exists at
t
double[-] The current time of the system
Returns
- Vector4
[-] The quaternion that is interpolated between the two
LinearInterpolate(double, double, double)
Linear interpolation between two doubles with some point in time.
public static double LinearInterpolate(double a, double b, double t)
Parameters
Returns
- double
An interpolated value
LinearInterpolate(double, double, double, double, double)
Linear Interpolates between two doubles based on an alpha between 0 and 1.
public static double LinearInterpolate(double a, double b, double t_a, double t_b, double t)
Parameters
a
doubleThe first value
b
doubleThe second value
t_a
doubleThe time of the first value
t_b
doubleThe time of the second value
t
doubleThe current time to interpolate between
Returns
- double
The interpolated double
NormaliseAngle(double)
Normalises the angle to between 0 and 2 PI, assuming that it is within the bounds.
public static double NormaliseAngle(double angle)
Parameters
angle
double[rad] The angle
Returns
- double
[rad] The normalised angle
NormaliseAngle(double, double, double)
Normalises the angle to between min and min + range, assuming that it is within the bounds.
public static double NormaliseAngle(double angle, double min, double range)
Parameters
angle
double[rad] The angle to normalise
min
double[rad] The minimum angle to check
range
double[rad] The range of the angle to normalise
Returns
- double
[rad] The normalised angle
QuadraticInterpolate(Vector2, Vector2, Vector2, double)
Quadratic interpolation between 3 vectors
public static Vector2 QuadraticInterpolate(Vector2 a, Vector2 b, Vector2 c, double t)
Parameters
Returns
- Vector2
An interpolated vector
QuadraticInterpolate(Vector3, Vector3, Vector3, double)
Quadratic interpolation between 3 vectors
public static Vector3 QuadraticInterpolate(Vector3 a, Vector3 b, Vector3 c, double t)
Parameters
Returns
- Vector3
a interpolated vector
QuadraticInterpolate(double, double, double, double)
Quadratic interpolation between 3 doubles
public static double QuadraticInterpolate(double a, double b, double c, double t)
Parameters
Returns
- double
An interpolated double
ShortestAngle(double, double)
Calculate the magnitude of the shortest angle between two angles, assuming they are measured in the same direction from the same reference accounting for the 2 PI -> 0 (4th to 1st) quadrant change.
public static double ShortestAngle(double angle1, double angle2)
Parameters
angle1
double[rad] The value of the first angle to consider
angle2
double[rad] The value of the second angle to consider
Returns
- double
[rad] The shortest angle
Slerp(Vector4, Vector4, double)
Determines the Spherical LERP between two quaternions based on some scaling factor. This is done by performing an angle rotation and some spherical mathematics.
public static Vector4 Slerp(Vector4 q1, Vector4 q2, double alpha)
Parameters
q1
Vector4[-] The 'from' quaternion
q2
Vector4[-] The 'to' quaternion
alpha
double[-] The scaling factor between the two quaternions
Returns
- Vector4
[-] The SLERP quaternion based on alpha
Slerp(Vector4, Vector4, double, double, double)
Determines the Spherical LERP between two quaternions based on some scaling factor. This is done by performing an angle rotation and some spherical mathematics.
public static Vector4 Slerp(Vector4 q1, Vector4 q2, double t1, double t2, double t)
Parameters
q1
Vector4[-] The 'from' quaternion
q2
Vector4[-] The 'to' quaternion
t1
double[-] The first time that the 'from' quaternion exists at
t2
double[-] The second time that the 'to' quaternion exists at
t
double[-] The current time of the system
Returns
- Vector4
[-] The SLERP quaternion based on time points