mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-28 14:08:25 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
// <auto-generated /> - edit Vector.math-metric.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct floatQuat
|
||||
{
|
||||
/// <inheritdoc cref="Quaternion.Length" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float Length()
|
||||
{
|
||||
return float.Sqrt(LengthSquared());
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Quaternion.LengthSquared" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float LengthSquared()
|
||||
{
|
||||
return Dot(this, this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Quaternion.Dot" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Dot(floatQuat a, floatQuat 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 floatQuat Normalize(floatQuat value)
|
||||
{
|
||||
var lengthSquared = Dot(value, value);
|
||||
if (lengthSquared == 0)
|
||||
throw new DivideByZeroException();
|
||||
return value / float.Sqrt(lengthSquared);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Quaternion.Normalize" />
|
||||
/// <remarks>Returns zero if the input quaternion is zero.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static floatQuat NormalizeOrZero(floatQuat value)
|
||||
{
|
||||
var length = float.Sqrt(Dot(value, value));
|
||||
return length == 0 ? Zero : value / length;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue