mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,62 @@
|
|||
// <auto-generated /> - edit Vector.math-metric.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct float3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float Length()
|
||||
{
|
||||
return float.Sqrt(LengthSquared());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly float LengthSquared()
|
||||
{
|
||||
return Dot(this, this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Distance" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Distance(float3 a, float3 b)
|
||||
{
|
||||
return float.Sqrt(DistanceSquared(a, b));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.DistanceSquared" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float DistanceSquared(float3 a, float3 b)
|
||||
{
|
||||
var difference = a - b;
|
||||
return Dot(difference, difference);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Dot" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float Dot(float3 a, float3 b)
|
||||
{
|
||||
return a.X * b.X + a.Y * b.Y + a.Z * b.Z;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Normalize" />
|
||||
/// <exception cref="DivideByZeroException">Thrown when the input vector is a zero vector.</exception>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3 Normalize(float3 value)
|
||||
{
|
||||
var lengthSquared = Dot(value, value);
|
||||
if (lengthSquared == 0)
|
||||
throw new DivideByZeroException();
|
||||
return value / float.Sqrt(lengthSquared);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float3 NormalizeOrZero(float3 value)
|
||||
{
|
||||
var length = float.Sqrt(Dot(value, value));
|
||||
return length == 0 ? Zero : value / length;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue