// - edit Vector.math-metric.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct doubleQuat
{
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly double Length()
{
return double.Sqrt(LengthSquared());
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly double LengthSquared()
{
return Dot(this, this);
}
///
[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;
}
///
/// Thrown when the input quaternion is a zero quaternion.
[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);
}
///
/// Returns zero if the input quaternion is zero.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static doubleQuat NormalizeOrZero(doubleQuat value)
{
var length = double.Sqrt(Dot(value, value));
return length == 0 ? Zero : value / length;
}
}