mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-28 05:58:25 +01:00
first
This commit is contained in:
parent
bd62d51ec9
commit
b578433e37
1 changed files with 784842 additions and 0 deletions
62
Brutal.Numerics/Vector/double3/double3.math-metric.gen.cs
Normal file
62
Brutal.Numerics/Vector/double3/double3.math-metric.gen.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// <auto-generated /> - edit Vector.math-metric.tt to modify
|
||||
#nullable enable
|
||||
|
||||
namespace Brutal.Numerics;
|
||||
|
||||
public partial struct double3
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly double Length()
|
||||
{
|
||||
return double.Sqrt(LengthSquared());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly double LengthSquared()
|
||||
{
|
||||
return Dot(this, this);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Distance" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double Distance(double3 a, double3 b)
|
||||
{
|
||||
return double.Sqrt(DistanceSquared(a, b));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.DistanceSquared" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double DistanceSquared(double3 a, double3 b)
|
||||
{
|
||||
var difference = a - b;
|
||||
return Dot(difference, difference);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Vector3.Dot" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double Dot(double3 a, double3 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 double3 Normalize(double3 value)
|
||||
{
|
||||
var lengthSquared = Dot(value, value);
|
||||
if (lengthSquared == 0)
|
||||
throw new DivideByZeroException();
|
||||
return value / double.Sqrt(lengthSquared);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double3 NormalizeOrZero(double3 value)
|
||||
{
|
||||
var length = double.Sqrt(Dot(value, value));
|
||||
return length == 0 ? Zero : value / length;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue