Dynamics/Utils.cs
using System;
using System.Runtime.CompilerServices;
using Sandbox;
namespace Andicraft.SecondOrderDynamics;
public static class Utils
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Wrap( float v, float min, float max )
{
return v - (max - min) * MathF.Floor( v / (max - min));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot( this Rotation a, Rotation b )
{
return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}
/// <summary>
/// Like HLSL saturate function
/// </summary>
/// <returns>Value clamped between 0 and 1</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Saturate( this float v )
{
return v.Clamp( 0, 1 );
}
}