mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 20:48:24 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
93
Brutal.Numerics/Vector/float4/float4.math.gen.cs
Normal file
93
Brutal.Numerics/Vector/float4/float4.math.gen.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
// <auto-generated /> - edit Vector.math.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float4
|
||||
{
|
||||
/// <inheritdoc cref="float4.Multiply(float4, float4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float4 Multiply(float4 vector, float4x4 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(float4, float4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float4 operator *(float4 vector, float4x4 matrix)
|
||||
{
|
||||
return Multiply(vector, matrix);
|
||||
}
|
||||
|
||||
/// <summary>Reflects a vector off the hyperplane with the given unit normal.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float4 Reflect(float4 vector, float4 normal)
|
||||
{
|
||||
return vector - 2 * Dot(vector, normal) * normal;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector4.Transform(Vector2, Matrix4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float4 Transform(float2 position, float4x4 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 float4 Transform(float2 value, floatQuat rotation)
|
||||
{
|
||||
// widen in a register: x, y, 0, 1
|
||||
var wide = Unsafe.BitCast<Vector128<float>, float4>(Vector128.Create(value.X, value.Y, 0.0f, 1.0f));
|
||||
return Transform(wide, rotation);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector4.Transform(Vector3, Matrix4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float4 Transform(float3 position, float4x4 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 float4 Transform(float3 value, floatQuat rotation)
|
||||
{
|
||||
// widen in a register: x, y, z, 1
|
||||
var wide = Unsafe.BitCast<Vector128<float>, float4>(Vector128.Create(value.X, value.Y, value.Z, 1.0f));
|
||||
return Transform(wide, rotation);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector4.Transform(Vector4, Matrix4x4)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float4 Transform(float4 vector, float4x4 matrix)
|
||||
{
|
||||
return Multiply(vector, matrix);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector4.Transform(Vector4, Quaternion)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float4 Transform(float4 value, floatQuat rotation)
|
||||
{
|
||||
var conjugate = floatQuat.Conjugate(rotation);
|
||||
var temp = floatQuat.Concatenate(conjugate, Unsafe.BitCast<float4, floatQuat>(value));
|
||||
return Unsafe.BitCast<floatQuat, float4>(floatQuat.Concatenate(temp, rotation));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue