brutal/Brutal.Numerics/Plane/floatPlane/floatPlane.numerics.gen.cs
Rian Drake b578433e37 first
2026-10-15 17:10:50 +13:00

80 lines
2.9 KiB
C#

// <auto-generated /> - edit Plane.numerics.tt to modify
#nullable enable
namespace Brutal.Numerics;
public partial struct floatPlane
{
/// <inheritdoc cref="Plane.CreateFromVertices(Vector3, Vector3, Vector3)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static floatPlane CreateFromVertices(float3 point1, float3 point2, float3 point3)
{
var normal = float3.Normalize(float3.Cross(point2 - point1, point3 - point1));
return new floatPlane(normal, -float3.Dot(normal, point1));
}
/// <inheritdoc cref="Plane.Dot(Plane, Vector4)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(floatPlane plane, float4 value)
{
return float4.Dot(plane.AsFloat4(), value);
}
/// <inheritdoc cref="Plane.DotCoordinate(Plane, Vector3)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float DotCoordinate(floatPlane plane, float3 value)
{
return Dot(plane, new float4(value, 1));
}
/// <inheritdoc cref="Plane.DotNormal(Plane, Vector3)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float DotNormal(floatPlane plane, float3 value)
{
return float3.Dot(plane.Normal, value);
}
/// <inheritdoc cref="Plane.Normalize(Plane)" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static floatPlane Normalize(floatPlane value)
{
var lengthSquared = value.Normal.LengthSquared();
if (lengthSquared == float.PositiveInfinity)
return default;
var length = float.Sqrt(lengthSquared);
return new floatPlane(value.Normal / length, value.D / length);
}
/// <inheritdoc cref="Plane.Normalize(Plane)" />
/// <remarks>Returns a zero plane if the input plane is zero</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static floatPlane NormalizeOrZero(floatPlane value)
{
var normalLengthSquared = value.Normal.LengthSquared();
if (normalLengthSquared == 0)
return new floatPlane(float3.Zero, 0);
if (normalLengthSquared == float.PositiveInfinity)
return default;
var length = float.Sqrt(normalLengthSquared);
return new floatPlane(value.Normal / length, value.D / length);
}
/// <inheritdoc cref="Plane.Transform(Plane, Matrix4x4)" />
// deliberately not AggressiveInlining, either overload: this one composes a full matrix Invert
public static floatPlane Transform(floatPlane plane, float4x4 matrix)
{
float4x4.Invert(matrix, out var inverseMatrix);
return FromFloat4(float4.Transform(plane.AsFloat4(), float4x4.Transpose(inverseMatrix)));
}
/// <inheritdoc cref="Plane.Transform(Plane, Quaternion)" />
public static floatPlane Transform(floatPlane plane, floatQuat rotation)
{
return FromFloat4(float4.Transform(plane.AsFloat4(), rotation));
}
}