mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
// <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;
|
|
}
|
|
}
|