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

97 lines
3.4 KiB
C#

// <auto-generated /> - edit Vector.math.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct double4
{
/// <inheritdoc cref="float4.Multiply(float4, float4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Multiply(double4 vector, double4x4 matrix)
{
var result = matrix.X * vector.X;
result += matrix.Y * vector.Y;
result += matrix.Z * vector.Z;
result += matrix.W * vector.W;
return result;
}
/// <inheritdoc cref="Multiply(double4, double4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator *(double4 vector, double4x4 matrix)
{
return Multiply(vector, matrix);
}
/// <summary>Reflects a vector off the hyperplane with the given unit normal.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Reflect(double4 vector, double4 normal)
{
return vector - 2 * Dot(vector, normal) * normal;
}
/// <inheritdoc cref="Vector4.Transform(Vector2, Matrix4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double2 position, double4x4 matrix)
{
var result = matrix.X * position.X;
result += matrix.Y * position.Y;
result += matrix.W;
return result;
}
/// <inheritdoc cref="Vector4.Transform(Vector2, Quaternion)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double2 value, doubleQuat rotation)
{
// widen in a register: x, y, 0, 1
var wide = Vector256.IsHardwareAccelerated
? Unsafe.BitCast<Vector256<double>, double4>(Vector256.Create(value.X, value.Y, 0.0, 1.0))
: new double4(value, 0, 1);
return Transform(wide, rotation);
}
/// <inheritdoc cref="Vector4.Transform(Vector3, Matrix4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 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;
}
/// <inheritdoc cref="Vector4.Transform(Vector3, Quaternion)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double3 value, doubleQuat rotation)
{
// widen in a register: x, y, z, 1
var wide = Vector256.IsHardwareAccelerated
? Unsafe.BitCast<Vector256<double>, double4>(Vector256.Create(value.X, value.Y, value.Z, 1.0))
: new double4(value, 1);
return Transform(wide, rotation);
}
/// <inheritdoc cref="Vector4.Transform(Vector4, Matrix4x4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double4 vector, double4x4 matrix)
{
return Multiply(vector, matrix);
}
/// <inheritdoc cref="Vector4.Transform(Vector4, Quaternion)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double4 value, doubleQuat rotation)
{
var conjugate = doubleQuat.Conjugate(rotation);
var temp = doubleQuat.Concatenate(conjugate, Unsafe.BitCast<double4, doubleQuat>(value));
return Unsafe.BitCast<doubleQuat, double4>(doubleQuat.Concatenate(temp, rotation));
}
}