mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08:24 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
123
Brutal.Numerics/Vector/byte3/byte3.gen.cs
Normal file
123
Brutal.Numerics/Vector/byte3/byte3.gen.cs
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// <auto-generated /> - edit Vector.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
/// <summary>
|
||||
/// Implements a 3D vector with byte components.
|
||||
/// </summary>
|
||||
[DebuggerTypeProxy(typeof(VectorDebugView3<byte3, byte, float>))]
|
||||
public partial struct byte3 : IVector3<byte3, byte>
|
||||
, IIntegerVector<byte3, byte, int, float>
|
||||
, ICrossProduct<byte3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static int ComponentSize => sizeof(byte);
|
||||
|
||||
/// <summary>Gets the number of components.</summary>
|
||||
public static int ComponentCount => 3;
|
||||
|
||||
/// <inheritdoc cref="Vector3.X" />
|
||||
[XmlAttribute]
|
||||
public byte X;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Y" />
|
||||
[XmlAttribute]
|
||||
public byte Y;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Z" />
|
||||
[XmlAttribute]
|
||||
public byte Z;
|
||||
|
||||
byte IVector3<byte3, byte>.X { readonly get => X; set => X = value; }
|
||||
|
||||
byte IVector3<byte3, byte>.Y { readonly get => Y; set => Y = value; }
|
||||
|
||||
byte IVector3<byte3, byte>.Z { readonly get => Z; set => Z = value; }
|
||||
|
||||
/// <inheritdoc cref="Vector3(float, float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte3(byte x, byte y, byte z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte3(byte xyz)
|
||||
: this(xyz, xyz, xyz) { }
|
||||
|
||||
/// <inheritdoc cref="Vector3(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte3(byte2 xy, byte 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 byte3(ReadOnlySpan<byte> span)
|
||||
{
|
||||
if (span.Length < 3)
|
||||
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 3.");
|
||||
|
||||
this = Unsafe.ReadUnaligned<byte3>(ref Unsafe.As<byte, byte>(ref MemoryMarshal.GetReference(span)));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="byte3(ReadOnlySpan{byte})" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static byte3 IComponentTuple<byte3, byte>.Create(ReadOnlySpan<byte> span) => new(span);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static byte3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static byte3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static byte3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <inheritdoc />
|
||||
public byte 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 byte x, out byte y, out byte z)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<byte> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.CreateSpan(ref Unsafe.As<byte3, byte>(ref this), 3);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ReadOnlySpan<byte> AsReadOnlySpan()
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<byte3, byte>(ref Unsafe.AsRef(in this)), 3);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue