brutal/Brutal.Numerics/Quaternion/doubleQuat/doubleQuat.math-metric.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

48 lines
1.6 KiB
C#

// <auto-generated /> - edit Vector.math-metric.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct doubleQuat
{
/// <inheritdoc cref="Quaternion.Length" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly double Length()
{
return double.Sqrt(LengthSquared());
}
/// <inheritdoc cref="Quaternion.LengthSquared" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly double LengthSquared()
{
return Dot(this, this);
}
/// <inheritdoc cref="Quaternion.Dot" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double Dot(doubleQuat a, doubleQuat b)
{
return a.X * b.X + a.Y * b.Y + a.Z * b.Z + a.W * b.W;
}
/// <inheritdoc cref="Quaternion.Normalize" />
/// <exception cref="DivideByZeroException">Thrown when the input quaternion is a zero quaternion.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static doubleQuat Normalize(doubleQuat value)
{
var lengthSquared = Dot(value, value);
if (lengthSquared == 0)
throw new DivideByZeroException();
return value / double.Sqrt(lengthSquared);
}
/// <inheritdoc cref="Quaternion.Normalize" />
/// <remarks>Returns zero if the input quaternion is zero.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static doubleQuat NormalizeOrZero(doubleQuat value)
{
var length = double.Sqrt(Dot(value, value));
return length == 0 ? Zero : value / length;
}
}