brutal/Brutal.Numerics/Vector/long3/long3.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

123 lines
3.8 KiB
C#

// <auto-generated /> - edit Vector.tt to modify
#nullable enable
namespace Brutal.Numerics;
/// <summary>
/// Implements a 3D vector with long components.
/// </summary>
[DebuggerTypeProxy(typeof(VectorDebugView3<long3, long, double>))]
public partial struct long3 : IVector3<long3, long>
, ISignedIntegerVector<long3, long, long, double>
, ICrossProduct<long3>
{
/// <inheritdoc />
public static int ComponentSize => sizeof(long);
/// <summary>Gets the number of components.</summary>
public static int ComponentCount => 3;
/// <inheritdoc cref="Vector3.X" />
[XmlAttribute]
public long X;
/// <inheritdoc cref="Vector3.Y" />
[XmlAttribute]
public long Y;
/// <inheritdoc cref="Vector3.Z" />
[XmlAttribute]
public long Z;
long IVector3<long3, long>.X { readonly get => X; set => X = value; }
long IVector3<long3, long>.Y { readonly get => Y; set => Y = value; }
long IVector3<long3, long>.Z { readonly get => Z; set => Z = value; }
/// <inheritdoc cref="Vector3(float, float, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long3(long x, long y, long z)
{
X = x;
Y = y;
Z = z;
}
/// <inheritdoc cref="Vector3(float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long3(long xyz)
: this(xyz, xyz, xyz) { }
/// <inheritdoc cref="Vector3(Vector2, float)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long3(long2 xy, long z)
: this(xy.X, xy.Y, z) { }
/// <summary>Creates a vector from the leading 3 elements of a span.</summary>
/// <param name="span">The elements to read; must contain at least 3, and any beyond that are ignored.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="span" /> holds fewer than 3 elements.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long3(ReadOnlySpan<long> span)
{
if (span.Length < 3)
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 3.");
this = Unsafe.ReadUnaligned<long3>(ref Unsafe.As<long, byte>(ref MemoryMarshal.GetReference(span)));
}
/// <inheritdoc cref="long3(ReadOnlySpan{long})" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long3 IComponentTuple<long3, long>.Create(ReadOnlySpan<long> span) => new(span);
/// <inheritdoc />
public static long3 UnitX => new(1, 0, 0);
/// <inheritdoc />
public static long3 UnitY => new(0, 1, 0);
/// <inheritdoc />
public static long3 UnitZ => new(0, 0, 1);
/// <inheritdoc />
public long 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 long x, out long y, out long z)
{
x = X;
y = Y;
z = Z;
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<long> AsSpan()
{
return MemoryMarshal.CreateSpan(ref Unsafe.As<long3, long>(ref this), 3);
}
/// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<long> AsReadOnlySpan()
{
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<long3, long>(ref Unsafe.AsRef(in this)), 3);
}
}