30 lines
877 B
C#
30 lines
877 B
C#
using System;
|
|
|
|
namespace VeloX.Utils;
|
|
|
|
public static class MathM
|
|
{
|
|
|
|
/// <summary>
|
|
/// Converts angular velocity (rad/s) to rotations per minute.
|
|
/// </summary>
|
|
public static float AngularVelocityToRPM( this float angularVelocity ) => angularVelocity * 9.5492965855137f;
|
|
|
|
/// <summary>
|
|
/// Converts rotations per minute to angular velocity (rad/s).
|
|
/// </summary>
|
|
public static float RPMToAngularVelocity( this float RPM ) => RPM * 0.10471975511966f;
|
|
|
|
public static float SignedAngle( this Vector3 from, Vector3 to, Vector3 axis )
|
|
{
|
|
float unsignedAngle = Vector3.GetAngle( from, to );
|
|
|
|
float cross_x = from.y * to.z - from.z * to.y;
|
|
float cross_y = from.z * to.x - from.x * to.z;
|
|
float cross_z = from.x * to.y - from.y * to.x;
|
|
float sign = MathF.Sign( axis.x * cross_x + axis.y * cross_y + axis.z * cross_z );
|
|
return unsignedAngle * sign;
|
|
}
|
|
|
|
}
|