// - edit Vector.math.tt to modify #nullable enable namespace Brutal.Numerics; public partial struct float3 { /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float3 Cross(float3 a, float3 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); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float2 Multiply(float3 vector, float3x2 matrix) { float2 result = default; result.X = Dot(vector, new float3(matrix.M11, matrix.M21, matrix.M31)); result.Y = Dot(vector, new float3(matrix.M12, matrix.M22, matrix.M32)); return result; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float2 operator *(float3 vector, float3x2 matrix) { return Multiply(vector, matrix); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float3 Reflect(float3 vector, float3 normal) { return vector - 2 * Dot(vector, normal) * normal; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float3 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.XYZ; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float3 Transform(float3 value, floatQuat rotation) { return float4.Transform(value, rotation).XYZ; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float3 TransformNormal(float3 normal, float4x4 matrix) { var result = matrix.X * normal.X; result += matrix.Y * normal.Y; result += matrix.Z * normal.Z; return result.XYZ; } }