brutal/brutal.numerics/Brutal.Numerics/Quaternion/doubleQuat/doubleQuat.gen.cs
2026-10-15 14:12:02 +13:00

116 lines
3.7 KiB
C#

// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a quaternion with double components.
/// </summary>
[DebuggerTypeProxy(typeof(QuaternionDebugView<doubleQuat, double>))]
public partial struct doubleQuat : IQuaternion<doubleQuat, double>
, IMultiplyOperators<doubleQuat, double2, double2>
, IMultiplyOperators<doubleQuat, double3, double3>
, IMultiplyOperators<doubleQuat, double4, double4>
, IQuaternionFactories<doubleQuat, double, double3, double4x4>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(double);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 4;
/// <inheritdoc cref="Quaternion.X" />
[XmlAttribute]
public double X;
/// <inheritdoc cref="Quaternion.Y" />
[XmlAttribute]
public double Y;
/// <inheritdoc cref="Quaternion.Z" />
[XmlAttribute]
public double Z;
/// <inheritdoc cref="Quaternion.W" />
[XmlAttribute]
public double W;
/// <inheritdoc cref="Quaternion(float, float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public doubleQuat(double x, double y, double z, double w)
{
X = x;
Y = y;
Z = z;
W = w;
}
/// <inheritdoc cref="Quaternion(Vector3, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public doubleQuat(double3 vectorPart, double scalarPart)
{
X = vectorPart.X;
Y = vectorPart.Y;
Z = vectorPart.Z;
W = scalarPart;
}
/// <summary>Creates a quaternion from the leading 4 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 4, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 4 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public doubleQuat(ReadOnlySpan<double> span)
{
if (span.Length < 4)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 4.");
this = Unsafe.ReadUnaligned<doubleQuat>(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="doubleQuat(ReadOnlySpan{double})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static doubleQuat IComponentTuple<doubleQuat, double>.Create(ReadOnlySpan<double> span) => new(span);
/// <inheritdoc />
public double this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
readonly get
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
return Unsafe.Add(ref Unsafe.AsRef(in X), index);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= ComponentCount)
throw new ArgumentOutOfRangeException(nameof(index));
Unsafe.Add(ref X, index) = value;
}
}
public readonly void Deconstruct(out double x, out double y, out double z, out double w)
{
x = X;
y = Y;
z = Z;
w = W;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<double> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<doubleQuat, double>(ref this), 4);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<double> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<doubleQuat, double>(ref Unsafe.AsRef(in this)), 4);
}
}