WuhuIslandTesting/Library/PackageCache/com.unity.splines@1.0.1/Editor/Utilities/MathUtility.cs

19 lines
615 B
C#
Raw Permalink Normal View History

2025-01-07 02:06:59 +01:00
using UnityEngine;
using Unity.Mathematics;
namespace UnityEditor.Splines
{
static class MathUtility
{
public static float GetRollAroundAxis(quaternion q, float3 axis)
{
axis = math.normalize(axis);
var orthoAxis = math.cross(axis, axis.Equals(math.up()) ? math.right() : math.up());
var rotatedOrtho = math.rotate(q, orthoAxis);
var flattened = math.normalize(Vector3.ProjectOnPlane(rotatedOrtho, axis));
var angle = Mathf.Deg2Rad * Vector3.SignedAngle(orthoAxis, flattened, axis);
return angle;
}
}
}