// - edit Vector.math.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct double4
{
///
[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;
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 operator *(double4 vector, double4x4 matrix)
{
return Multiply(vector, matrix);
}
/// Reflects a vector off the hyperplane with the given unit normal.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Reflect(double4 vector, double4 normal)
{
return vector - 2 * Dot(vector, normal) * normal;
}
///
[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;
}
///
[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, double4>(Vector256.Create(value.X, value.Y, 0.0, 1.0))
: new double4(value, 0, 1);
return Transform(wide, rotation);
}
///
[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;
}
///
[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, double4>(Vector256.Create(value.X, value.Y, value.Z, 1.0))
: new double4(value, 1);
return Transform(wide, rotation);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double4 vector, double4x4 matrix)
{
return Multiply(vector, matrix);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static double4 Transform(double4 value, doubleQuat rotation)
{
var conjugate = doubleQuat.Conjugate(rotation);
var temp = doubleQuat.Concatenate(conjugate, Unsafe.BitCast(value));
return Unsafe.BitCast(doubleQuat.Concatenate(temp, rotation));
}
}