mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58: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/float3/float3.gen.cs
Normal file
123
Brutal.Numerics/Vector/float3/float3.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 float components.
|
||||
/// </summary>
|
||||
[DebuggerTypeProxy(typeof(VectorDebugView3<float3, float, float>))]
|
||||
public partial struct float3 : IVector3<float3, float>
|
||||
, IFloatingVector<float3, float>
|
||||
, IFloatingVector3<float3, float, float2, floatQuat, float3x2, float4x4>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static int ComponentSize => sizeof(float);
|
||||
|
||||
/// <summary>Gets the number of components.</summary>
|
||||
public static int ComponentCount => 3;
|
||||
|
||||
/// <inheritdoc cref="Vector3.X" />
|
||||
[XmlAttribute]
|
||||
public float X;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Y" />
|
||||
[XmlAttribute]
|
||||
public float Y;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Z" />
|
||||
[XmlAttribute]
|
||||
public float Z;
|
||||
|
||||
float IVector3<float3, float>.X { readonly get => X; set => X = value; }
|
||||
|
||||
float IVector3<float3, float>.Y { readonly get => Y; set => Y = value; }
|
||||
|
||||
float IVector3<float3, float>.Z { readonly get => Z; set => Z = value; }
|
||||
|
||||
/// <inheritdoc cref="Vector3(float, float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float3(float x, float y, float z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float3(float xyz)
|
||||
: this(xyz, xyz, xyz) { }
|
||||
|
||||
/// <inheritdoc cref="Vector3(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float3(float2 xy, float 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 float3(ReadOnlySpan<float> span)
|
||||
{
|
||||
if (span.Length < 3)
|
||||
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 3.");
|
||||
|
||||
this = Unsafe.ReadUnaligned<float3>(ref Unsafe.As<float, byte>(ref MemoryMarshal.GetReference(span)));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="float3(ReadOnlySpan{float})" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static float3 IComponentTuple<float3, float>.Create(ReadOnlySpan<float> span) => new(span);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static float3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static float3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static float3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <inheritdoc />
|
||||
public float 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 float x, out float y, out float z)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<float> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.CreateSpan(ref Unsafe.As<float3, float>(ref this), 3);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ReadOnlySpan<float> AsReadOnlySpan()
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<float3, float>(ref Unsafe.AsRef(in this)), 3);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue