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
11 changed files with 784842 additions and 0 deletions
28
Brutal.Numerics/Vector/double3/double3.copy.gen.cs
Normal file
28
Brutal.Numerics/Vector/double3/double3.copy.gen.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// <auto-generated /> - edit Vector.copy.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void CopyTo(Span<double> destination)
|
||||
{
|
||||
if (destination.Length < ComponentCount)
|
||||
throw new ArgumentException("Length must be at least 3.", nameof(destination));
|
||||
|
||||
Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(destination)), this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool TryCopyTo(Span<double> destination)
|
||||
{
|
||||
if (destination.Length < ComponentCount)
|
||||
return false;
|
||||
|
||||
Unsafe.WriteUnaligned(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(destination)), this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
41
Brutal.Numerics/Vector/double3/double3.equality.gen.cs
Normal file
41
Brutal.Numerics/Vector/double3/double3.equality.gen.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// <auto-generated /> - edit Vector.equality.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public readonly override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(X, Y, Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(double3 other)
|
||||
{
|
||||
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly override bool Equals([NotNullWhen(true)] object? obj)
|
||||
{
|
||||
return obj is double3 other && Equals(other);
|
||||
}
|
||||
|
||||
/// <summary>IEEE lane-wise equality over every component: any NaN component makes this false (contrast <see cref="Equals(double3)" />, which is NaN-reflexive), and -0 equals +0.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(double3 a, double3 b)
|
||||
{
|
||||
return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(double3 a, double3 b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
}
|
||||
92
Brutal.Numerics/Vector/double3/double3.format.gen.cs
Normal file
92
Brutal.Numerics/Vector/double3/double3.format.gen.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
// <auto-generated /> - edit Vector.format.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3 : ISpanFormattable, IUtf8SpanFormattable, ISpanParsable<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public readonly override string ToString()
|
||||
{
|
||||
return ToString("G", CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.ToString(string?)" />
|
||||
public readonly string ToString(string? format)
|
||||
{
|
||||
return ToString(format, CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly string ToString(string? format, IFormatProvider? formatProvider)
|
||||
{
|
||||
var separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator;
|
||||
return $"<{X.ToString(format, formatProvider)}{separator} {Y.ToString(format, formatProvider)}{separator} {Z.ToString(format, formatProvider)}>";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
return StringHelpers.TryFormat<double3, double>(this, destination, out charsWritten, format, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public readonly bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
|
||||
{
|
||||
return StringHelpers.TryFormat<double3, double>(this, destination, out bytesWritten, format, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static double3 Parse(string s, IFormatProvider? provider)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(s);
|
||||
return Parse(s.AsSpan(), NumberStyles.Float, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static double3 Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
|
||||
{
|
||||
return Parse(s, NumberStyles.Float, provider);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Parse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?)" />
|
||||
public static double3 Parse(string s, NumberStyles style, IFormatProvider? provider)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(s);
|
||||
return Parse(s.AsSpan(), style, provider);
|
||||
}
|
||||
|
||||
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
||||
/// <exception cref="FormatException">The input is not in a valid format, or a component fails to parse.</exception>
|
||||
public static double3 Parse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider)
|
||||
{
|
||||
if (!TryParse(s, style, provider, out var result))
|
||||
throw new FormatException($"'{s}' is not in a valid double3 format.");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double3)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out double3 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), NumberStyles.Float, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double3)" />
|
||||
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out double3 result)
|
||||
{
|
||||
return TryParse(s, NumberStyles.Float, provider, out result);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="TryParse(ReadOnlySpan{char}, NumberStyles, IFormatProvider?, out double3)" />
|
||||
public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out double3 result)
|
||||
{
|
||||
return TryParse(s.AsSpan(), style, provider, out result);
|
||||
}
|
||||
|
||||
/// <summary>Parses from the <see cref="ToString()" /> format, <c><1, 2, 3></c>.</summary>
|
||||
/// <returns>true if the input parsed as a double3.</returns>
|
||||
public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out double3 result)
|
||||
{
|
||||
return StringHelpers.TryParse<double3, double>(s, style, provider, out result);
|
||||
}
|
||||
}
|
||||
123
Brutal.Numerics/Vector/double3/double3.gen.cs
Normal file
123
Brutal.Numerics/Vector/double3/double3.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 double components.
|
||||
/// </summary>
|
||||
[DebuggerTypeProxy(typeof(VectorDebugView3<double3, double, double>))]
|
||||
public partial struct double3 : IVector3<double3, double>
|
||||
, IFloatingVector<double3, double>
|
||||
, IFloatingVector3<double3, double, double2, doubleQuat, double3x2, double4x4>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static int ComponentSize => sizeof(double);
|
||||
|
||||
/// <summary>Gets the number of components.</summary>
|
||||
public static int ComponentCount => 3;
|
||||
|
||||
/// <inheritdoc cref="Vector3.X" />
|
||||
[XmlAttribute]
|
||||
public double X;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Y" />
|
||||
[XmlAttribute]
|
||||
public double Y;
|
||||
|
||||
/// <inheritdoc cref="Vector3.Z" />
|
||||
[XmlAttribute]
|
||||
public double Z;
|
||||
|
||||
double IVector3<double3, double>.X { readonly get => X; set => X = value; }
|
||||
|
||||
double IVector3<double3, double>.Y { readonly get => Y; set => Y = value; }
|
||||
|
||||
double IVector3<double3, double>.Z { readonly get => Z; set => Z = value; }
|
||||
|
||||
/// <inheritdoc cref="Vector3(float, float, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double3(double x, double y, double z)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3(float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double3(double xyz)
|
||||
: this(xyz, xyz, xyz) { }
|
||||
|
||||
/// <inheritdoc cref="Vector3(Vector2, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double3(double2 xy, double 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 double3(ReadOnlySpan<double> span)
|
||||
{
|
||||
if (span.Length < 3)
|
||||
throw new ArgumentOutOfRangeException(nameof(span), "Length must be at least 3.");
|
||||
|
||||
this = Unsafe.ReadUnaligned<double3>(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(span)));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double3(ReadOnlySpan{double})" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double3 IComponentTuple<double3, double>.Create(ReadOnlySpan<double> span) => new(span);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double3 UnitX => new(1, 0, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double3 UnitY => new(0, 1, 0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double3 UnitZ => new(0, 0, 1);
|
||||
|
||||
/// <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)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<double> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.CreateSpan(ref Unsafe.As<double3, double>(ref this), 3);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly ReadOnlySpan<double> AsReadOnlySpan()
|
||||
{
|
||||
return MemoryMarshal.CreateReadOnlySpan(in Unsafe.As<double3, double>(ref Unsafe.AsRef(in this)), 3);
|
||||
}
|
||||
}
|
||||
62
Brutal.Numerics/Vector/double3/double3.math-metric.gen.cs
Normal file
62
Brutal.Numerics/Vector/double3/double3.math-metric.gen.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// <auto-generated /> - edit Vector.math-metric.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly double Length()
|
||||
{
|
||||
return double.Sqrt(LengthSquared());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly double LengthSquared()
|
||||
{
|
||||
return Dot(this, this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Distance" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double Distance(double3 a, double3 b)
|
||||
{
|
||||
return double.Sqrt(DistanceSquared(a, b));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.DistanceSquared" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double DistanceSquared(double3 a, double3 b)
|
||||
{
|
||||
var difference = a - b;
|
||||
return Dot(difference, difference);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Dot" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double Dot(double3 a, double3 b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y + a.Z * b.Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Normalize" />
|
||||
/// <exception cref="DivideByZeroException">Thrown when the input vector is a zero vector.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Normalize(double3 value)
|
||||
{
|
||||
var lengthSquared = Dot(value, value);
|
||||
if (lengthSquared == 0)
|
||||
throw new DivideByZeroException();
|
||||
return value / double.Sqrt(lengthSquared);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 NormalizeOrZero(double3 value)
|
||||
{
|
||||
var length = double.Sqrt(Dot(value, value));
|
||||
return length == 0 ? Zero : value / length;
|
||||
}
|
||||
}
|
||||
75
Brutal.Numerics/Vector/double3/double3.math.gen.cs
Normal file
75
Brutal.Numerics/Vector/double3/double3.math.gen.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
// <auto-generated /> - edit Vector.math.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
/// <inheritdoc cref="Vector3.Cross" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Cross(double3 a, double3 b)
|
||||
{
|
||||
return new(
|
||||
a.Y * b.Z - a.Z * b.Y,
|
||||
a.Z * b.X - a.X * b.Z,
|
||||
a.X * b.Y - a.Y * b.X);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="float4.Multiply(float4, float4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 Multiply(double3 vector, double3x2 matrix)
|
||||
{
|
||||
double2 result = default;
|
||||
|
||||
result.X = Dot(vector, new double3(matrix.M11, matrix.M21, matrix.M31));
|
||||
result.Y = Dot(vector, new double3(matrix.M12, matrix.M22, matrix.M32));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Multiply(double3, double3x2)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double2 operator *(double3 vector, double3x2 matrix)
|
||||
{
|
||||
return Multiply(vector, matrix);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Reflect" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Reflect(double3 vector, double3 normal)
|
||||
{
|
||||
return vector - 2 * Dot(vector, normal) * normal;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Transform(Vector3, Matrix4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Transform(double3 position, double4x4 matrix)
|
||||
{
|
||||
var result = matrix.X * position.X;
|
||||
|
||||
result += matrix.Y * position.Y;
|
||||
result += matrix.Z * position.Z;
|
||||
result += matrix.W;
|
||||
|
||||
return result.XYZ;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Transform(Vector3, Quaternion)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Transform(double3 value, doubleQuat rotation)
|
||||
{
|
||||
return double4.Transform(value, rotation).XYZ;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.TransformNormal(Vector3, Matrix4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 TransformNormal(double3 normal, double4x4 matrix)
|
||||
{
|
||||
var result = matrix.X * normal.X;
|
||||
|
||||
result += matrix.Y * normal.Y;
|
||||
result += matrix.Z * normal.Z;
|
||||
|
||||
return result.XYZ;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// <auto-generated /> - edit Vector.numerics-binary.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// IBinaryNumber
|
||||
public partial struct double3 : IBinaryNumber<double3>
|
||||
{
|
||||
/// <summary>Determines if every component of a value is a power of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool IBinaryNumber<double3>.IsPow2(double3 value)
|
||||
{
|
||||
return double.IsPow2(value.X) && double.IsPow2(value.Y) && double.IsPow2(value.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double3 IBitwiseOperators<double3, double3, double3>.operator &(double3 a, double3 b)
|
||||
{
|
||||
return Unsafe.BitCast<long3, double3>(Unsafe.BitCast<double3, long3>(a) & Unsafe.BitCast<double3, long3>(b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double3 IBitwiseOperators<double3, double3, double3>.operator |(double3 a, double3 b)
|
||||
{
|
||||
return Unsafe.BitCast<long3, double3>(Unsafe.BitCast<double3, long3>(a) | Unsafe.BitCast<double3, long3>(b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double3 IBitwiseOperators<double3, double3, double3>.operator ^(double3 a, double3 b)
|
||||
{
|
||||
return Unsafe.BitCast<long3, double3>(Unsafe.BitCast<double3, long3>(a) ^ Unsafe.BitCast<double3, long3>(b));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static double3 IBitwiseOperators<double3, double3, double3>.operator ~(double3 value)
|
||||
{
|
||||
return Unsafe.BitCast<long3, double3>(~Unsafe.BitCast<double3, long3>(value));
|
||||
}
|
||||
}
|
||||
|
||||
// the componentwise predicate mask (no interface to mirror) - the per-lane truth IsPow2 collapses
|
||||
public partial struct double3
|
||||
{
|
||||
/// <summary>Determines which components of a value are powers of two.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsPow2(double3 value)
|
||||
{
|
||||
return new bool3(double.IsPow2(value.X), double.IsPow2(value.Y), double.IsPow2(value.Z));
|
||||
}
|
||||
}
|
||||
442
Brutal.Numerics/Vector/double3/double3.numerics-floating.gen.cs
Normal file
442
Brutal.Numerics/Vector/double3/double3.numerics-floating.gen.cs
Normal file
|
|
@ -0,0 +1,442 @@
|
|||
// <auto-generated /> - edit Vector.numerics-floating.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// IFloatingPointConstants
|
||||
public partial struct double3 : IFloatingPointConstants<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static double3 E => new(double.E);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double3 Pi => new(double.Pi);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double3 Tau => new(double.Tau);
|
||||
}
|
||||
|
||||
// IExponentialFunctions
|
||||
public partial struct double3 : IExponentialFunctions<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Exp(double3 value)
|
||||
{
|
||||
return new(double.Exp(value.X), double.Exp(value.Y), double.Exp(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Exp2(double3 value)
|
||||
{
|
||||
return new double3(double.Exp2(value.X), double.Exp2(value.Y), double.Exp2(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Exp10(double3 value)
|
||||
{
|
||||
return new double3(double.Exp10(value.X), double.Exp10(value.Y), double.Exp10(value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// ILogarithmicFunctions
|
||||
public partial struct double3 : ILogarithmicFunctions<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Log(double3 value)
|
||||
{
|
||||
return new(double.Log(value.X), double.Log(value.Y), double.Log(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Log(double3 value, double3 newBase)
|
||||
{
|
||||
return new double3(double.Log(value.X, newBase.X), double.Log(value.Y, newBase.Y), double.Log(value.Z, newBase.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Log2(double3 value)
|
||||
{
|
||||
return new(double.Log2(value.X), double.Log2(value.Y), double.Log2(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Log10(double3 value)
|
||||
{
|
||||
return new double3(double.Log10(value.X), double.Log10(value.Y), double.Log10(value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// IPowerFunctions
|
||||
public partial struct double3 : IPowerFunctions<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Pow(double3 value, double3 power)
|
||||
{
|
||||
return new double3(double.Pow(value.X, power.X), double.Pow(value.Y, power.Y), double.Pow(value.Z, power.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// IRootFunctions
|
||||
public partial struct double3 : IRootFunctions<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Cbrt(double3 value)
|
||||
{
|
||||
return new double3(double.Cbrt(value.X), double.Cbrt(value.Y), double.Cbrt(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Hypot(double3 a, double3 b)
|
||||
{
|
||||
return new(double.Hypot(a.X, b.X), double.Hypot(a.Y, b.Y), double.Hypot(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 RootN(double3 value, int n)
|
||||
{
|
||||
return new double3(double.RootN(value.X, n), double.RootN(value.Y, n), double.RootN(value.Z, n));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Sqrt(double3 value)
|
||||
{
|
||||
return new(double.Sqrt(value.X), double.Sqrt(value.Y), double.Sqrt(value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// ITrigonometricFunctions
|
||||
public partial struct double3 : ITrigonometricFunctions<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Sin(double3 value)
|
||||
{
|
||||
return new(double.Sin(value.X), double.Sin(value.Y), double.Sin(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Cos(double3 value)
|
||||
{
|
||||
return new(double.Cos(value.X), double.Cos(value.Y), double.Cos(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static (double3 Sin, double3 Cos) SinCos(double3 value)
|
||||
{
|
||||
var (sinX, cosX) = double.SinCos(value.X);
|
||||
var (sinY, cosY) = double.SinCos(value.Y);
|
||||
var (sinZ, cosZ) = double.SinCos(value.Z);
|
||||
return (new(sinX, sinY, sinZ), new(cosX, cosY, cosZ));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Tan(double3 value)
|
||||
{
|
||||
return new double3(double.Tan(value.X), double.Tan(value.Y), double.Tan(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Asin(double3 value)
|
||||
{
|
||||
return new double3(double.Asin(value.X), double.Asin(value.Y), double.Asin(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Acos(double3 value)
|
||||
{
|
||||
return new double3(double.Acos(value.X), double.Acos(value.Y), double.Acos(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Atan(double3 value)
|
||||
{
|
||||
return new double3(double.Atan(value.X), double.Atan(value.Y), double.Atan(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 SinPi(double3 value)
|
||||
{
|
||||
return new double3(double.SinPi(value.X), double.SinPi(value.Y), double.SinPi(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 CosPi(double3 value)
|
||||
{
|
||||
return new double3(double.CosPi(value.X), double.CosPi(value.Y), double.CosPi(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 TanPi(double3 value)
|
||||
{
|
||||
return new double3(double.TanPi(value.X), double.TanPi(value.Y), double.TanPi(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 AsinPi(double3 value)
|
||||
{
|
||||
return new double3(double.AsinPi(value.X), double.AsinPi(value.Y), double.AsinPi(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 AcosPi(double3 value)
|
||||
{
|
||||
return new double3(double.AcosPi(value.X), double.AcosPi(value.Y), double.AcosPi(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 AtanPi(double3 value)
|
||||
{
|
||||
return new double3(double.AtanPi(value.X), double.AtanPi(value.Y), double.AtanPi(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static (double3 SinPi, double3 CosPi) SinCosPi(double3 value)
|
||||
{
|
||||
return (SinPi(value), CosPi(value));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.DegreesToRadians" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 DegreesToRadians(double3 degrees)
|
||||
{
|
||||
return new(double.DegreesToRadians(degrees.X), double.DegreesToRadians(degrees.Y), double.DegreesToRadians(degrees.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.RadiansToDegrees" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 RadiansToDegrees(double3 radians)
|
||||
{
|
||||
return new(double.RadiansToDegrees(radians.X), double.RadiansToDegrees(radians.Y), double.RadiansToDegrees(radians.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// IHyperbolicFunctions
|
||||
public partial struct double3 : IHyperbolicFunctions<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Sinh(double3 value)
|
||||
{
|
||||
return new double3(double.Sinh(value.X), double.Sinh(value.Y), double.Sinh(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Cosh(double3 value)
|
||||
{
|
||||
return new double3(double.Cosh(value.X), double.Cosh(value.Y), double.Cosh(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Tanh(double3 value)
|
||||
{
|
||||
return new double3(double.Tanh(value.X), double.Tanh(value.Y), double.Tanh(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Asinh(double3 value)
|
||||
{
|
||||
return new double3(double.Asinh(value.X), double.Asinh(value.Y), double.Asinh(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Acosh(double3 value)
|
||||
{
|
||||
return new double3(double.Acosh(value.X), double.Acosh(value.Y), double.Acosh(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Atanh(double3 value)
|
||||
{
|
||||
return new double3(double.Atanh(value.X), double.Atanh(value.Y), double.Atanh(value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// IFloatingPoint
|
||||
public partial struct double3 : IFloatingPoint<double3>
|
||||
{
|
||||
/// <inheritdoc cref="double.Floor(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Floor(double3 value)
|
||||
{
|
||||
return new(double.Floor(value.X), double.Floor(value.Y), double.Floor(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Ceiling(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Ceiling(double3 value)
|
||||
{
|
||||
return new(double.Ceiling(value.X), double.Ceiling(value.Y), double.Ceiling(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Round(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Round(double3 value)
|
||||
{
|
||||
return new(double.Round(value.X), double.Round(value.Y), double.Round(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Truncate(double)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Truncate(double3 value)
|
||||
{
|
||||
return new(double.Truncate(value.X), double.Truncate(value.Y), double.Truncate(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Round(double, int, MidpointRounding)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Round(double3 value, int digits, MidpointRounding mode)
|
||||
{
|
||||
return new double3(double.Round(value.X, digits, mode), double.Round(value.Y, digits, mode), double.Round(value.Z, digits, mode));
|
||||
}
|
||||
|
||||
// One exponent and significand PER LANE, so there is no single honest answer: explicit and throwing.
|
||||
|
||||
int IFloatingPoint<double3>.GetExponentByteCount() =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one exponent per component.");
|
||||
|
||||
int IFloatingPoint<double3>.GetExponentShortestBitLength() =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one exponent per component.");
|
||||
|
||||
int IFloatingPoint<double3>.GetSignificandBitLength() =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one significand per component.");
|
||||
|
||||
int IFloatingPoint<double3>.GetSignificandByteCount() =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one significand per component.");
|
||||
|
||||
bool IFloatingPoint<double3>.TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one exponent per component.");
|
||||
|
||||
bool IFloatingPoint<double3>.TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one exponent per component.");
|
||||
|
||||
bool IFloatingPoint<double3>.TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one significand per component.");
|
||||
|
||||
bool IFloatingPoint<double3>.TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one significand per component.");
|
||||
}
|
||||
|
||||
// IFloatingPointIeee754
|
||||
public partial struct double3 : IFloatingPointIeee754<double3>
|
||||
{
|
||||
/// <summary>Gets a vector whose components are NaN.</summary>
|
||||
public static double3 NaN => new(double.NaN);
|
||||
|
||||
/// <inheritdoc cref="double.Epsilon" />
|
||||
public static double3 Epsilon => new(double.Epsilon);
|
||||
|
||||
/// <inheritdoc cref="double.NegativeZero" />
|
||||
public static double3 NegativeZero => new(double.NegativeZero);
|
||||
|
||||
/// <inheritdoc cref="double.PositiveInfinity" />
|
||||
public static double3 PositiveInfinity => new(double.PositiveInfinity);
|
||||
|
||||
/// <inheritdoc cref="double.NegativeInfinity" />
|
||||
public static double3 NegativeInfinity => new(double.NegativeInfinity);
|
||||
|
||||
/// <inheritdoc cref="double.Atan2" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Atan2(double3 y, double3 x)
|
||||
{
|
||||
return new double3(double.Atan2(y.X, x.X), double.Atan2(y.Y, x.Y), double.Atan2(y.Z, x.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Atan2Pi" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Atan2Pi(double3 y, double3 x)
|
||||
{
|
||||
return new double3(double.Atan2Pi(y.X, x.X), double.Atan2Pi(y.Y, x.Y), double.Atan2Pi(y.Z, x.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.BitDecrement" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 BitDecrement(double3 value)
|
||||
{
|
||||
return new double3(double.BitDecrement(value.X), double.BitDecrement(value.Y), double.BitDecrement(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.BitIncrement" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 BitIncrement(double3 value)
|
||||
{
|
||||
return new double3(double.BitIncrement(value.X), double.BitIncrement(value.Y), double.BitIncrement(value.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.FusedMultiplyAdd" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 FusedMultiplyAdd(double3 a, double3 b, double3 addend)
|
||||
{
|
||||
return new(double.FusedMultiplyAdd(a.X, b.X, addend.X), double.FusedMultiplyAdd(a.Y, b.Y, addend.Y), double.FusedMultiplyAdd(a.Z, b.Z, addend.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.MultiplyAddEstimate" />
|
||||
/// <remarks>Permitted but not required to fuse; use <see cref="FusedMultiplyAdd" /> where the single rounding is required.</remarks>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 MultiplyAddEstimate(double3 a, double3 b, double3 addend)
|
||||
{
|
||||
return new(double.MultiplyAddEstimate(a.X, b.X, addend.X), double.MultiplyAddEstimate(a.Y, b.Y, addend.Y), double.MultiplyAddEstimate(a.Z, b.Z, addend.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.Ieee754Remainder" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Ieee754Remainder(double3 a, double3 b)
|
||||
{
|
||||
return new double3(double.Ieee754Remainder(a.X, b.X), double.Ieee754Remainder(a.Y, b.Y), double.Ieee754Remainder(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="double.ScaleB" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 ScaleB(double3 value, int n)
|
||||
{
|
||||
return new double3(double.ScaleB(value.X, n), double.ScaleB(value.Y, n), double.ScaleB(value.Z, n));
|
||||
}
|
||||
|
||||
// ILogB's int return cannot hold one exponent per lane - same shape as Sign
|
||||
static int IFloatingPointIeee754<double3>.ILogB(double3 value) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has one exponent per component.");
|
||||
|
||||
/// <inheritdoc cref="Vector3.Lerp(Vector3, Vector3, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Lerp(double3 a, double3 b, double amount)
|
||||
{
|
||||
return new(double.Lerp(a.X, b.X, amount), double.Lerp(a.Y, b.Y, amount), double.Lerp(a.Z, b.Z, amount));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Sqrt" />
|
||||
[Obsolete("Renamed to Sqrt (the generic-math name; SquareRoot was the System.Numerics vector spelling).")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 SquareRoot(double3 value)
|
||||
{
|
||||
return Sqrt(value);
|
||||
}
|
||||
}
|
||||
545
Brutal.Numerics/Vector/double3/double3.numerics.gen.cs
Normal file
545
Brutal.Numerics/Vector/double3/double3.numerics.gen.cs
Normal file
|
|
@ -0,0 +1,545 @@
|
|||
// <auto-generated /> - edit Vector.numerics.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
// INumberBase
|
||||
public partial struct double3 : INumberBase<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static double3 Zero => new(0);
|
||||
|
||||
/// <inheritdoc />
|
||||
public static double3 One => new(1);
|
||||
|
||||
static double3 IAdditiveIdentity<double3, double3>.AdditiveIdentity => Zero;
|
||||
|
||||
static double3 IMultiplicativeIdentity<double3, double3>.MultiplicativeIdentity => One;
|
||||
|
||||
static int INumberBase<double3>.Radix => 2; // every component type is binary
|
||||
|
||||
/// <inheritdoc cref="Vector3.Abs" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Abs(double3 value)
|
||||
{
|
||||
return new(double.Abs(value.X), double.Abs(value.Y), double.Abs(value.Z));
|
||||
}
|
||||
|
||||
static bool INumberBase<double3>.IsCanonical(double3 value) => true;
|
||||
|
||||
static bool INumberBase<double3>.IsComplexNumber(double3 value) => false;
|
||||
|
||||
static bool INumberBase<double3>.IsImaginaryNumber(double3 value) => false;
|
||||
|
||||
/// <summary>Determines if every component of a value is zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsZero(double3 value)
|
||||
{
|
||||
return value == Zero;
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsEvenInteger(double3 value)
|
||||
{
|
||||
return double.IsEvenInteger(value.X) && double.IsEvenInteger(value.Y) && double.IsEvenInteger(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsOddInteger(double3 value)
|
||||
{
|
||||
return double.IsOddInteger(value.X) && double.IsOddInteger(value.Y) && double.IsOddInteger(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is negative.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsNegative(double3 value)
|
||||
{
|
||||
return double.IsNegative(value.X) && double.IsNegative(value.Y) && double.IsNegative(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is positive.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsPositive(double3 value)
|
||||
{
|
||||
return double.IsPositive(value.X) && double.IsPositive(value.Y) && double.IsPositive(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is finite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsFinite(double3 value)
|
||||
{
|
||||
return double.IsFinite(value.X) && double.IsFinite(value.Y) && double.IsFinite(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is infinite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsInfinity(double3 value)
|
||||
{
|
||||
return double.IsInfinity(value.X) && double.IsInfinity(value.Y) && double.IsInfinity(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is negative infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsNegativeInfinity(double3 value)
|
||||
{
|
||||
return double.IsNegativeInfinity(value.X) && double.IsNegativeInfinity(value.Y) && double.IsNegativeInfinity(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is positive infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsPositiveInfinity(double3 value)
|
||||
{
|
||||
return double.IsPositiveInfinity(value.X) && double.IsPositiveInfinity(value.Y) && double.IsPositiveInfinity(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is an integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsInteger(double3 value)
|
||||
{
|
||||
return double.IsInteger(value.X) && double.IsInteger(value.Y) && double.IsInteger(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is a real value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsRealNumber(double3 value)
|
||||
{
|
||||
return double.IsRealNumber(value.X) && double.IsRealNumber(value.Y) && double.IsRealNumber(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if any component of a value is NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsNaN(double3 value)
|
||||
{
|
||||
return double.IsNaN(value.X) || double.IsNaN(value.Y) || double.IsNaN(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is normal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsNormal(double3 value)
|
||||
{
|
||||
return double.IsNormal(value.X) && double.IsNormal(value.Y) && double.IsNormal(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines if every component of a value is subnormal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static bool INumberBase<double3>.IsSubnormal(double3 value)
|
||||
{
|
||||
return double.IsSubnormal(value.X) && double.IsSubnormal(value.Y) && double.IsSubnormal(value.Z);
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 MaxMagnitude(double3 a, double3 b)
|
||||
{
|
||||
return new(double.MaxMagnitude(a.X, b.X), double.MaxMagnitude(a.Y, b.Y), double.MaxMagnitude(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is greater, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 MaxMagnitudeNumber(double3 a, double3 b)
|
||||
{
|
||||
return new(double.MaxMagnitudeNumber(a.X, b.X), double.MaxMagnitudeNumber(a.Y, b.Y), double.MaxMagnitudeNumber(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 MinMagnitude(double3 a, double3 b)
|
||||
{
|
||||
return new(double.MinMagnitude(a.X, b.X), double.MinMagnitude(a.Y, b.Y), double.MinMagnitude(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Computes, componentwise, the value whose magnitude is smaller, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 MinMagnitudeNumber(double3 a, double3 b)
|
||||
{
|
||||
return new(double.MinMagnitudeNumber(a.X, b.X), double.MinMagnitudeNumber(a.Y, b.Y), double.MinMagnitudeNumber(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Add" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Add(double3 a, double3 b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Divide(Vector3, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Divide(double3 a, double3 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Multiply(Vector3, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Multiply(double3 a, double3 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Negate" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Negate(double3 value)
|
||||
{
|
||||
return -value;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Subtract" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Subtract(double3 a, double3 b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator +(double3 a, double3 b)
|
||||
{
|
||||
return new(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator -(double3 a, double3 b)
|
||||
{
|
||||
return new(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator *(double3 a, double3 b)
|
||||
{
|
||||
return new(a.X * b.X, a.Y * b.Y, a.Z * b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator /(double3 a, double3 b)
|
||||
{
|
||||
return new(a.X / b.X, a.Y / b.Y, a.Z / b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator -(double3 a)
|
||||
{
|
||||
return new(-a.X, -a.Y, -a.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator +(double3 a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
// ++/-- are well-defined (+/- One) but a footgun on a concrete vector: generic-plane only.
|
||||
|
||||
static double3 IIncrementOperators<double3>.operator ++(double3 value) => value + One;
|
||||
|
||||
static double3 IDecrementOperators<double3>.operator --(double3 value) => value - One;
|
||||
|
||||
|
||||
static bool INumberBase<double3>.TryConvertFromChecked<TOther>(TOther value, out double3 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<double3, double, TOther, NumberConversion.Checked>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<double3>.TryConvertToChecked<TOther>(double3 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<double3>.TryConvertFromSaturating<TOther>(TOther value, out double3 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<double3, double, TOther, NumberConversion.Saturating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<double3>.TryConvertToSaturating<TOther>(double3 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool INumberBase<double3>.TryConvertFromTruncating<TOther>(TOther value, out double3 result)
|
||||
{
|
||||
return NumberConversion.TryConvertFrom<double3, double, TOther, NumberConversion.Truncating>(value, out result);
|
||||
}
|
||||
|
||||
static bool INumberBase<double3>.TryConvertToTruncating<TOther>(double3 value, [MaybeNullWhen(false)] out TOther result)
|
||||
{
|
||||
result = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// IMultiplyOperators<TSelf, TComponent, TSelf>, IDivisionOperators<TSelf, TComponent, TSelf>
|
||||
public partial struct double3
|
||||
: IMultiplyOperators<double3, double, double3>
|
||||
, IDivisionOperators<double3, double, double3>
|
||||
{
|
||||
/// <inheritdoc cref="Vector3.Divide(Vector3, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Divide(double3 a, double b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Multiply(Vector3, float)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Multiply(double3 a, double b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Multiply(float, Vector3)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Multiply(double a, double3 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator *(double3 a, double b)
|
||||
{
|
||||
return new(a.X * b, a.Y * b, a.Z * b);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator /(double3 a, double b)
|
||||
{
|
||||
return new(a.X / b, a.Y / b, a.Z / b);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator *(double a, double3 b)
|
||||
{
|
||||
return new(a * b.X, a * b.Y, a * b.Z);
|
||||
}
|
||||
}
|
||||
|
||||
// INumber
|
||||
public partial struct double3 : INumber<double3>
|
||||
{
|
||||
/// <inheritdoc cref="Vector3.Clamp" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Clamp(double3 value, double3 min, double3 max)
|
||||
{
|
||||
// HLSL contract when min > max: max wins (clamp is Max-then-Min); pinned in
|
||||
// Clamp_InvertedBounds_MatchesBcl. NOT scalar T.Clamp, which throws on inversion.
|
||||
return Min(Max(value, min), max);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Max" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Max(double3 a, double3 b)
|
||||
{
|
||||
return new(double.Max(a.X, b.X), double.Max(a.Y, b.Y), double.Max(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Min" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 Min(double3 a, double3 b)
|
||||
{
|
||||
return new(double.Min(a.X, b.X), double.Min(a.Y, b.Y), double.Min(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Selects, componentwise, the larger value, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 MaxNumber(double3 a, double3 b)
|
||||
{
|
||||
return new(double.MaxNumber(a.X, b.X), double.MaxNumber(a.Y, b.Y), double.MaxNumber(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Selects, componentwise, the smaller value, preferring numbers over NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 MinNumber(double3 a, double3 b)
|
||||
{
|
||||
return new(double.MinNumber(a.X, b.X), double.MinNumber(a.Y, b.Y), double.MinNumber(a.Z, b.Z));
|
||||
}
|
||||
|
||||
/// <summary>Copies, componentwise, the sign of <paramref name="sign" /> onto the magnitude of <paramref name="value" />.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 CopySign(double3 value, double3 sign)
|
||||
{
|
||||
return new(double.CopySign(value.X, sign.X), double.CopySign(value.Y, sign.Y), double.CopySign(value.Z, sign.Z));
|
||||
}
|
||||
|
||||
// the Native variants permit either NaN/signed-zero behavior - forwarding is always legal
|
||||
static double3 INumber<double3>.ClampNative(double3 value, double3 min, double3 max) => Clamp(value, min, max);
|
||||
|
||||
static double3 INumber<double3>.MaxNative(double3 a, double3 b) => Max(a, b);
|
||||
|
||||
static double3 INumber<double3>.MinNative(double3 a, double3 b) => Min(a, b);
|
||||
|
||||
// Sign's int return cannot hold a per-lane answer, and a collapsed one would lie for mixed signs
|
||||
static int INumber<double3>.Sign(double3 value) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has no scalar sign.");
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 operator %(double3 a, double3 b)
|
||||
{
|
||||
return new double3(a.X % b.X, a.Y % b.Y, a.Z % b.Z);
|
||||
}
|
||||
|
||||
int IComparable.CompareTo(object? obj) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has no total order.");
|
||||
|
||||
int IComparable<double3>.CompareTo(double3 other) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double3, double3, bool>.operator <(double3 a, double3 b) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double3, double3, bool>.operator <=(double3 a, double3 b) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double3, double3, bool>.operator >(double3 a, double3 b) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has no total order.");
|
||||
|
||||
static bool IComparisonOperators<double3, double3, bool>.operator >=(double3 a, double3 b) =>
|
||||
throw new NotSupportedException($"{nameof(double3)} has no total order.");
|
||||
}
|
||||
|
||||
// IComponentwiseComparison + the componentwise predicate masks (no interface to mirror)
|
||||
public partial struct double3 : IComponentwiseComparison<double3, bool3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator <(double3 a, double3 b)
|
||||
{
|
||||
return new bool3(a.X < b.X, a.Y < b.Y, a.Z < b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator <=(double3 a, double3 b)
|
||||
{
|
||||
return new bool3(a.X <= b.X, a.Y <= b.Y, a.Z <= b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator >(double3 a, double3 b)
|
||||
{
|
||||
return new bool3(a.X > b.X, a.Y > b.Y, a.Z > b.Z);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 operator >=(double3 a, double3 b)
|
||||
{
|
||||
return new bool3(a.X >= b.X, a.Y >= b.Y, a.Z >= b.Z);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are zero.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsZero(double3 value)
|
||||
{
|
||||
return new bool3(value.X == 0, value.Y == 0, value.Z == 0);
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an even integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsEvenInteger(double3 value)
|
||||
{
|
||||
return new bool3(double.IsEvenInteger(value.X), double.IsEvenInteger(value.Y), double.IsEvenInteger(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an odd integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsOddInteger(double3 value)
|
||||
{
|
||||
return new bool3(double.IsOddInteger(value.X), double.IsOddInteger(value.Y), double.IsOddInteger(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are negative.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsNegative(double3 value)
|
||||
{
|
||||
return new bool3(double.IsNegative(value.X), double.IsNegative(value.Y), double.IsNegative(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are positive.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsPositive(double3 value)
|
||||
{
|
||||
return new bool3(double.IsPositive(value.X), double.IsPositive(value.Y), double.IsPositive(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are finite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsFinite(double3 value)
|
||||
{
|
||||
return new bool3(double.IsFinite(value.X), double.IsFinite(value.Y), double.IsFinite(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are infinite.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsInfinity(double3 value)
|
||||
{
|
||||
return new bool3(double.IsInfinity(value.X), double.IsInfinity(value.Y), double.IsInfinity(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are negative infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsNegativeInfinity(double3 value)
|
||||
{
|
||||
return new bool3(double.IsNegativeInfinity(value.X), double.IsNegativeInfinity(value.Y), double.IsNegativeInfinity(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are positive infinity.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsPositiveInfinity(double3 value)
|
||||
{
|
||||
return new bool3(double.IsPositiveInfinity(value.X), double.IsPositiveInfinity(value.Y), double.IsPositiveInfinity(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are an integral value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsInteger(double3 value)
|
||||
{
|
||||
return new bool3(double.IsInteger(value.X), double.IsInteger(value.Y), double.IsInteger(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are a real value.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsRealNumber(double3 value)
|
||||
{
|
||||
return new bool3(double.IsRealNumber(value.X), double.IsRealNumber(value.Y), double.IsRealNumber(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are NaN.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsNaN(double3 value)
|
||||
{
|
||||
return new bool3(double.IsNaN(value.X), double.IsNaN(value.Y), double.IsNaN(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are normal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsNormal(double3 value)
|
||||
{
|
||||
return new bool3(double.IsNormal(value.X), double.IsNormal(value.Y), double.IsNormal(value.Z));
|
||||
}
|
||||
|
||||
/// <summary>Determines which components of a value are subnormal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool3 IsSubnormal(double3 value)
|
||||
{
|
||||
return new bool3(double.IsSubnormal(value.X), double.IsSubnormal(value.Y), double.IsSubnormal(value.Z));
|
||||
}
|
||||
}
|
||||
|
||||
// ISignedNumber
|
||||
public partial struct double3 : ISignedNumber<double3>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public static double3 NegativeOne => new(-1);
|
||||
}
|
||||
210
Brutal.Numerics/Vector/double3/double3.pack.gen.cs
Normal file
210
Brutal.Numerics/Vector/double3/double3.pack.gen.cs
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
// <auto-generated /> - edit Vector.pack.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
public static double3 Unpack(in sbyte3 vector, Func<sbyte, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double3 Unpack(in byte3 vector, Func<byte, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double3 Unpack(in short3 vector, Func<short, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double3 Unpack(in ushort3 vector, Func<ushort, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double3 Unpack(in int3 vector, Func<int, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double3 Unpack(in uint3 vector, Func<uint, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double3 Unpack(in float3 vector, Func<float, double> elementConverter)
|
||||
{
|
||||
VectorPack.Pack(vector, out double3 result, elementConverter);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double3 Unpack(in sbyte3 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.SByte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double3 Unpack(in byte3 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Byte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double3 Unpack(in short3 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Short.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double3 Unpack(in ushort3 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.UShort.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double3 Unpack(in int3 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Int.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double3 Unpack(in uint3 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.UInt.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static double3 Unpack(in float3 vector, Unpack.Float mode = Numerics.Unpack.Float.Cast)
|
||||
{
|
||||
return Unpack(vector, PackUtils.Float.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte3> source,
|
||||
Span<double3> destination,
|
||||
Func<sbyte, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte3> source,
|
||||
Span<double3> destination,
|
||||
Func<byte, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<short3> source,
|
||||
Span<double3> destination,
|
||||
Func<short, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<ushort3> source,
|
||||
Span<double3> destination,
|
||||
Func<ushort, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<int3> source,
|
||||
Span<double3> destination,
|
||||
Func<int, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<uint3> source,
|
||||
Span<double3> destination,
|
||||
Func<uint, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<float3> source,
|
||||
Span<double3> destination,
|
||||
Func<float, double> elementConverter
|
||||
)
|
||||
{
|
||||
VectorPack.Pack(source, destination, elementConverter);
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<sbyte3> source,
|
||||
Span<double3> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.SByte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<byte3> source,
|
||||
Span<double3> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Byte.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<short3> source,
|
||||
Span<double3> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Short.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<ushort3> source,
|
||||
Span<double3> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.UShort.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<int3> source,
|
||||
Span<double3> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Int.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<uint3> source,
|
||||
Span<double3> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.UInt.ToDouble(mode));
|
||||
}
|
||||
|
||||
public static void UnpackSpan(
|
||||
in ReadOnlySpan<float3> source,
|
||||
Span<double3> destination,
|
||||
Unpack.Float mode = Numerics.Unpack.Float.Cast
|
||||
)
|
||||
{
|
||||
UnpackSpan(source, destination, PackUtils.Float.ToDouble(mode));
|
||||
}
|
||||
}
|
||||
400
Brutal.Numerics/Vector/double3/double3.swizzle.gen.cs
Normal file
400
Brutal.Numerics/Vector/double3/double3.swizzle.gen.cs
Normal file
|
|
@ -0,0 +1,400 @@
|
|||
// <auto-generated /> - edit Vector.swizzle.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the X and Y components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 XY
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(X, Y);
|
||||
set
|
||||
{
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the X and Z components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 XZ
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(X, Z);
|
||||
set
|
||||
{
|
||||
X = value.X;
|
||||
Z = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Y and X components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 YX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X);
|
||||
set
|
||||
{
|
||||
Y = value.X;
|
||||
X = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Y and Z components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 YZ
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, Z);
|
||||
set
|
||||
{
|
||||
Y = value.X;
|
||||
Z = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Z and X components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 ZX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, X);
|
||||
set
|
||||
{
|
||||
Z = value.X;
|
||||
X = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Z and Y components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 ZY
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, Y);
|
||||
set
|
||||
{
|
||||
Z = value.X;
|
||||
Y = value.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the X, Y and Z components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 XYZ
|
||||
{
|
||||
readonly get => this;
|
||||
set => this = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the X, Z and Y components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 XZY
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(X, Z, Y);
|
||||
set
|
||||
{
|
||||
X = value.X;
|
||||
Z = value.Y;
|
||||
Y = value.Z;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Y, X and Z components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 YXZ
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X, Z);
|
||||
set
|
||||
{
|
||||
Y = value.X;
|
||||
X = value.Y;
|
||||
Z = value.Z;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Y, Z and X components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 YZX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, Z, X);
|
||||
set
|
||||
{
|
||||
Y = value.X;
|
||||
Z = value.Y;
|
||||
X = value.Z;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Z, X and Y components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 ZXY
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, X, Y);
|
||||
set
|
||||
{
|
||||
Z = value.X;
|
||||
X = value.Y;
|
||||
Y = value.Z;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Z, Y and X components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 ZYX
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, Y, X);
|
||||
set
|
||||
{
|
||||
Z = value.X;
|
||||
Y = value.Y;
|
||||
X = value.Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
/// <summary>
|
||||
/// The Red component of the vector (synonym for X).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double R
|
||||
{
|
||||
readonly get => X;
|
||||
set => X = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Green component of the vector (synonym for Y).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double G
|
||||
{
|
||||
readonly get => Y;
|
||||
set => Y = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Blue component of the vector (synonym for Z).
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double B
|
||||
{
|
||||
readonly get => Z;
|
||||
set => Z = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Red and Green components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 RG
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(R, G);
|
||||
set
|
||||
{
|
||||
R = value.R;
|
||||
G = value.G;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Red and Blue components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 RB
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(R, B);
|
||||
set
|
||||
{
|
||||
R = value.R;
|
||||
B = value.G;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Green and Red components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 GR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(G, R);
|
||||
set
|
||||
{
|
||||
G = value.R;
|
||||
R = value.G;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Green and Blue components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 GB
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(G, B);
|
||||
set
|
||||
{
|
||||
G = value.R;
|
||||
B = value.G;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Blue and Red components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 BR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(B, R);
|
||||
set
|
||||
{
|
||||
B = value.R;
|
||||
R = value.G;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Blue and Green components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double2 BG
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(B, G);
|
||||
set
|
||||
{
|
||||
B = value.R;
|
||||
G = value.G;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Red, Green, and Blue components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 RGB
|
||||
{
|
||||
readonly get => this;
|
||||
set => this = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Red, Blue, and Green components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 RBG
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(X, Z, Y);
|
||||
set
|
||||
{
|
||||
R = value.R;
|
||||
B = value.G;
|
||||
G = value.B;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Green, Red, and Blue components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 GRB
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, X, Z);
|
||||
set
|
||||
{
|
||||
G = value.R;
|
||||
R = value.G;
|
||||
B = value.B;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Green, Blue, and Red components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 GBR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Y, Z, X);
|
||||
set
|
||||
{
|
||||
G = value.R;
|
||||
B = value.G;
|
||||
R = value.B;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Blue, Red, and Green components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 BRG
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, X, Y);
|
||||
set
|
||||
{
|
||||
B = value.R;
|
||||
R = value.G;
|
||||
G = value.B;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swizzle readonly getter/setter for the Blue, Green, and Red components of the vector.
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public double3 BGR
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => new(Z, Y, X);
|
||||
set
|
||||
{
|
||||
B = value.R;
|
||||
G = value.G;
|
||||
R = value.B;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue