Большое переименование: замена префикса F на более корректный FP (Floating Point)
This commit is contained in:
parent
c66edd3432
commit
ebb0a73555
31 changed files with 483 additions and 483 deletions
|
|
@ -23,18 +23,18 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public static class F32Angle
|
||||
public static class FP32Angle
|
||||
{
|
||||
public static float ToRadians(float angle, AngleUnit unit)
|
||||
{
|
||||
if (unit == AngleUnit.DEGREES)
|
||||
{
|
||||
return angle * F32Degrees.RADIANS_IN_DEGREE;
|
||||
return angle * FP32Degrees.RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.TURNS)
|
||||
{
|
||||
return angle * F32Radians.TWO_PI;
|
||||
return angle * FP32Radians.TWO_PI;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -44,7 +44,7 @@ namespace BGC
|
|||
{
|
||||
if (unit == AngleUnit.RADIANS)
|
||||
{
|
||||
return angle * F32Radians.DEGREES_IN_RADIAN;
|
||||
return angle * FP32Radians.DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.TURNS)
|
||||
|
|
@ -59,12 +59,12 @@ namespace BGC
|
|||
{
|
||||
if (unit == AngleUnit.RADIANS)
|
||||
{
|
||||
return angle * F32Radians.TURNS_IN_RADIAN;
|
||||
return angle * FP32Radians.TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.DEGREES)
|
||||
{
|
||||
return angle * F32Degrees.TURNS_IN_DEGREE;
|
||||
return angle * FP32Degrees.TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -82,7 +82,7 @@ namespace BGC
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
return F32Radians.TWO_PI;
|
||||
return FP32Radians.TWO_PI;
|
||||
}
|
||||
|
||||
public static float GetHalfCircle(AngleUnit unit)
|
||||
|
|
@ -97,7 +97,7 @@ namespace BGC
|
|||
return 0.5f;
|
||||
}
|
||||
|
||||
return F32Radians.PI;
|
||||
return FP32Radians.PI;
|
||||
}
|
||||
|
||||
public static float GetQuarterCircle(AngleUnit unit)
|
||||
|
|
@ -112,22 +112,22 @@ namespace BGC
|
|||
return 0.25f;
|
||||
}
|
||||
|
||||
return F32Radians.HALF_OF_PI;
|
||||
return FP32Radians.HALF_OF_PI;
|
||||
}
|
||||
|
||||
public static float Normalize(float angle, AngleUnit unit, AngleRange range)
|
||||
{
|
||||
if (unit == AngleUnit.DEGREES)
|
||||
{
|
||||
return F32Degrees.Normalize(angle, range);
|
||||
return FP32Degrees.Normalize(angle, range);
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.TURNS)
|
||||
{
|
||||
return F32Turns.Normalize(angle, range);
|
||||
return FP32Turns.Normalize(angle, range);
|
||||
}
|
||||
|
||||
return F32Radians.Normalize(angle, range);
|
||||
return FP32Radians.Normalize(angle, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F32Degrees
|
||||
public class FP32Degrees
|
||||
{
|
||||
public const float RADIANS_IN_DEGREE = 1.745329252E-2f;
|
||||
public const float TURNS_IN_DEGREE = 2.7777777778E-3f;
|
||||
|
|
@ -23,13 +23,13 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Matrix2x2
|
||||
public struct FP32Matrix2x2
|
||||
{
|
||||
public float r1c1, r1c2;
|
||||
|
||||
public float r2c1, r2c2;
|
||||
|
||||
public F32Matrix2x2()
|
||||
public FP32Matrix2x2()
|
||||
{
|
||||
this.r1c1 = 0.0f;
|
||||
this.r1c2 = 0.0f;
|
||||
|
|
@ -38,7 +38,7 @@ namespace BGC
|
|||
this.r2c2 = 0.0f;
|
||||
}
|
||||
|
||||
public F32Matrix2x2(float d1, float d2)
|
||||
public FP32Matrix2x2(float d1, float d2)
|
||||
{
|
||||
this.r1c1 = d1;
|
||||
this.r1c2 = 0.0f;
|
||||
|
|
@ -47,7 +47,7 @@ namespace BGC
|
|||
this.r2c2 = d2;
|
||||
}
|
||||
|
||||
public F32Matrix2x2(in F32Matrix2x2 matrix)
|
||||
public FP32Matrix2x2(in FP32Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -56,7 +56,7 @@ namespace BGC
|
|||
this.r2c2 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public F32Matrix2x2(in F64Matrix2x2 matrix)
|
||||
public FP32Matrix2x2(in FP64Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = (float)matrix.r1c1;
|
||||
this.r1c2 = (float)matrix.r1c2;
|
||||
|
|
@ -73,7 +73,7 @@ namespace BGC
|
|||
public readonly bool IsSingular()
|
||||
{
|
||||
float determinant = this.GetDeterminant();
|
||||
return -F32Utility.EPSYLON <= determinant && determinant <= F32Utility.EPSYLON;
|
||||
return -FP32Utility.EPSYLON <= determinant && determinant <= FP32Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Transpose()
|
||||
|
|
@ -85,7 +85,7 @@ namespace BGC
|
|||
{
|
||||
float determinant = this.GetDeterminant();
|
||||
|
||||
if (-F32Utility.EPSYLON <= determinant && determinant <= F32Utility.EPSYLON)
|
||||
if (-FP32Utility.EPSYLON <= determinant && determinant <= FP32Utility.EPSYLON)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ namespace BGC
|
|||
this.r2c2 = d2;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Matrix2x2 matrix)
|
||||
public void SetValues(in FP32Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -141,7 +141,7 @@ namespace BGC
|
|||
this.r2c2 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Matrix2x2 matrix)
|
||||
public void SetValues(in FP64Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = (float)matrix.r1c1;
|
||||
this.r1c2 = (float)matrix.r1c2;
|
||||
|
|
@ -150,14 +150,14 @@ namespace BGC
|
|||
this.r2c2 = (float)matrix.r2c2;
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F32Matrix2x2 matrix)
|
||||
public void SetTransposedOf(in FP32Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r2c2 = matrix.r2c2;
|
||||
(this.r1c2, this.r2c1) = (matrix.r2c1, matrix.r1c2);
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F64Matrix2x2 matrix)
|
||||
public void SetTransposedOf(in FP64Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = (float)matrix.r1c1;
|
||||
this.r1c2 = (float)matrix.r2c1;
|
||||
|
|
@ -166,11 +166,11 @@ namespace BGC
|
|||
this.r2c2 = (float)matrix.r2c2;
|
||||
}
|
||||
|
||||
public bool SetInvertedOf(in F32Matrix2x2 matrix)
|
||||
public bool SetInvertedOf(in FP32Matrix2x2 matrix)
|
||||
{
|
||||
float determinant = matrix.GetDeterminant();
|
||||
|
||||
if (-F32Utility.EPSYLON <= determinant && determinant <= F32Utility.EPSYLON)
|
||||
if (-FP32Utility.EPSYLON <= determinant && determinant <= FP32Utility.EPSYLON)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ namespace BGC
|
|||
this.r2c2 = r2;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F32Matrix2x2 matrix, float scale)
|
||||
public void AppendScaled(in FP32Matrix2x2 matrix, float scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1 * scale;
|
||||
this.r1c2 += matrix.r1c2 * scale;
|
||||
|
|
@ -223,7 +223,7 @@ namespace BGC
|
|||
this.r2c2 += matrix.r2c2 * scale;
|
||||
}
|
||||
|
||||
public static void Add(in F32Matrix2x2 matrix1, in F32Matrix2x2 matrix2, out F32Matrix2x2 result)
|
||||
public static void Add(in FP32Matrix2x2 matrix1, in FP32Matrix2x2 matrix2, out FP32Matrix2x2 result)
|
||||
{
|
||||
result.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
result.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -232,7 +232,7 @@ namespace BGC
|
|||
result.r2c2 = matrix1.r2c2 + matrix2.r2c2;
|
||||
}
|
||||
|
||||
public static void Subtract(in F32Matrix2x2 minuend, in F32Matrix2x2 subtrahend, out F32Matrix2x2 difference)
|
||||
public static void Subtract(in FP32Matrix2x2 minuend, in FP32Matrix2x2 subtrahend, out FP32Matrix2x2 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -241,7 +241,7 @@ namespace BGC
|
|||
difference.r2c2 = minuend.r2c2 - subtrahend.r2c2;
|
||||
}
|
||||
|
||||
public static void Multiply(in F32Matrix2x2 multiplicand, float multiplier, out F32Matrix2x2 product)
|
||||
public static void Multiply(in FP32Matrix2x2 multiplicand, float multiplier, out FP32Matrix2x2 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -250,7 +250,7 @@ namespace BGC
|
|||
product.r2c2 = multiplicand.r2c2 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F32Matrix2x2 dividend, float divisor, out F32Matrix2x2 quotient)
|
||||
public static void Divide(in FP32Matrix2x2 dividend, float divisor, out FP32Matrix2x2 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -259,7 +259,7 @@ namespace BGC
|
|||
quotient.r2c2 = dividend.r2c2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F32Matrix2x2 matrix, in F32Vector2 vector, out F32Vector2 result)
|
||||
public static void GetRightProduct(in FP32Matrix2x2 matrix, in FP32Vector2 vector, out FP32Vector2 result)
|
||||
{
|
||||
float x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2;
|
||||
float x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2;
|
||||
|
|
@ -268,7 +268,7 @@ namespace BGC
|
|||
result.x2 = x2;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F32Vector2 vector, in F32Matrix2x2 matrix, out F32Vector2 result)
|
||||
public static void GetLeftProduct(in FP32Vector2 vector, in FP32Matrix2x2 matrix, out FP32Vector2 result)
|
||||
{
|
||||
float x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1;
|
||||
float x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2;
|
||||
|
|
@ -277,7 +277,7 @@ namespace BGC
|
|||
result.x2 = x2;
|
||||
}
|
||||
|
||||
public static void LoadZero(out F32Matrix2x2 matrix)
|
||||
public static void LoadZero(out FP32Matrix2x2 matrix)
|
||||
{
|
||||
matrix.r1c1 = 0.0f;
|
||||
matrix.r1c2 = 0.0f;
|
||||
|
|
@ -286,7 +286,7 @@ namespace BGC
|
|||
matrix.r2c2 = 0.0f;
|
||||
}
|
||||
|
||||
public static void LoadIdentity(out F32Matrix2x2 matrix)
|
||||
public static void LoadIdentity(out FP32Matrix2x2 matrix)
|
||||
{
|
||||
matrix.r1c1 = 1.0f;
|
||||
matrix.r1c2 = 0.0f;
|
||||
|
|
@ -295,7 +295,7 @@ namespace BGC
|
|||
matrix.r2c2 = 1.0f;
|
||||
}
|
||||
|
||||
public static void LoadDiagonal(float d1, float d2, out F32Matrix2x2 matrix)
|
||||
public static void LoadDiagonal(float d1, float d2, out FP32Matrix2x2 matrix)
|
||||
{
|
||||
matrix.r1c1 = d1;
|
||||
matrix.r1c2 = 0.0f;
|
||||
|
|
@ -22,13 +22,13 @@ using System;
|
|||
*/
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Matrix2x3
|
||||
public struct FP32Matrix2x3
|
||||
{
|
||||
public float r1c1, r1c2;
|
||||
public float r2c1, r2c2;
|
||||
public float r3c1, r3c2;
|
||||
|
||||
public F32Matrix2x3()
|
||||
public FP32Matrix2x3()
|
||||
{
|
||||
this.r1c1 = 0.0f;
|
||||
this.r1c2 = 0.0f;
|
||||
|
|
@ -40,7 +40,7 @@ namespace BGC
|
|||
this.r3c2 = 0.0f;
|
||||
}
|
||||
|
||||
public F32Matrix2x3(in F32Matrix2x3 matrix)
|
||||
public FP32Matrix2x3(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -52,7 +52,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public F32Matrix2x3(in F64Matrix2x3 matrix)
|
||||
public FP32Matrix2x3(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r1c2;
|
||||
|
|
@ -64,7 +64,7 @@ namespace BGC
|
|||
this.r3c2 = (float) matrix.r3c2;
|
||||
}
|
||||
|
||||
public F32Matrix2x3(in F32Matrix3x2 matrix)
|
||||
public FP32Matrix2x3(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -76,7 +76,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public F32Matrix2x3(in F64Matrix3x2 matrix)
|
||||
public FP32Matrix2x3(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r2c1;
|
||||
|
|
@ -100,7 +100,7 @@ namespace BGC
|
|||
this.r3c2 = 0.0f;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Matrix2x3 matrix)
|
||||
public void SetValues(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -112,7 +112,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Matrix2x3 matrix)
|
||||
public void SetValues(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r1c2;
|
||||
|
|
@ -124,7 +124,7 @@ namespace BGC
|
|||
this.r3c2 = (float) matrix.r3c2;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F32Matrix3x2 matrix)
|
||||
public void SetTransposed(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -136,7 +136,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F64Matrix3x2 matrix)
|
||||
public void SetTransposed(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r2c1;
|
||||
|
|
@ -180,7 +180,7 @@ namespace BGC
|
|||
this.r3c2 = r3;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F32Matrix2x3 matrix, float scale)
|
||||
public void AppendScaled(in FP32Matrix2x3 matrix, float scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1 * scale;
|
||||
this.r1c2 += matrix.r1c2 * scale;
|
||||
|
|
@ -192,7 +192,7 @@ namespace BGC
|
|||
this.r3c2 += matrix.r3c2 * scale;
|
||||
}
|
||||
|
||||
public static void Add(in F32Matrix2x3 matrix1, in F32Matrix2x3 matrix2, out F32Matrix2x3 sum)
|
||||
public static void Add(in FP32Matrix2x3 matrix1, in FP32Matrix2x3 matrix2, out FP32Matrix2x3 sum)
|
||||
{
|
||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -204,7 +204,7 @@ namespace BGC
|
|||
sum.r3c2 = matrix1.r3c2 + matrix2.r3c2;
|
||||
}
|
||||
|
||||
public static void Subtract(in F32Matrix2x3 minuend, in F32Matrix2x3 subtrahend, out F32Matrix2x3 difference)
|
||||
public static void Subtract(in FP32Matrix2x3 minuend, in FP32Matrix2x3 subtrahend, out FP32Matrix2x3 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -216,7 +216,7 @@ namespace BGC
|
|||
difference.r3c2 = minuend.r3c2 - subtrahend.r3c2;
|
||||
}
|
||||
|
||||
public static void Multiply(in F32Matrix2x3 multiplicand, float multiplier, out F32Matrix2x3 product)
|
||||
public static void Multiply(in FP32Matrix2x3 multiplicand, float multiplier, out FP32Matrix2x3 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -228,7 +228,7 @@ namespace BGC
|
|||
product.r3c2 = multiplicand.r3c2 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F32Matrix2x3 dividend, float divisor, out F32Matrix2x3 quotient)
|
||||
public static void Divide(in FP32Matrix2x3 dividend, float divisor, out FP32Matrix2x3 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -240,14 +240,14 @@ namespace BGC
|
|||
quotient.r3c2 = dividend.r3c2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F32Matrix2x3 matrix, in F32Vector2 vector, out F32Vector3 result)
|
||||
public static void GetRightProduct(in FP32Matrix2x3 matrix, in FP32Vector2 vector, out FP32Vector3 result)
|
||||
{
|
||||
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2;
|
||||
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2;
|
||||
result.x3 = matrix.r3c1 * vector.x1 + matrix.r3c2 * vector.x2;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F32Vector3 vector, in F32Matrix2x3 matrix, out F32Vector2 result)
|
||||
public static void GetLeftProduct(in FP32Vector3 vector, in FP32Matrix2x3 matrix, out FP32Vector2 result)
|
||||
{
|
||||
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1;
|
||||
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2;
|
||||
|
|
@ -20,12 +20,12 @@
|
|||
*/
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Matrix3x2
|
||||
public struct FP32Matrix3x2
|
||||
{
|
||||
public float r1c1, r1c2, r1c3;
|
||||
public float r2c1, r2c2, r2c3;
|
||||
|
||||
public F32Matrix3x2()
|
||||
public FP32Matrix3x2()
|
||||
{
|
||||
this.r1c1 = 0.0f;
|
||||
this.r1c2 = 0.0f;
|
||||
|
|
@ -36,7 +36,7 @@ namespace BGC
|
|||
this.r2c3 = 0.0f;
|
||||
}
|
||||
|
||||
public F32Matrix3x2(in F32Matrix3x2 matrix)
|
||||
public FP32Matrix3x2(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -47,7 +47,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public F32Matrix3x2(in F64Matrix3x2 matrix)
|
||||
public FP32Matrix3x2(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r1c2;
|
||||
|
|
@ -58,7 +58,7 @@ namespace BGC
|
|||
this.r2c3 = (float) matrix.r2c3;
|
||||
}
|
||||
|
||||
public F32Matrix3x2(in F32Matrix2x3 matrix)
|
||||
public FP32Matrix3x2(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -69,7 +69,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public F32Matrix3x2(in F64Matrix2x3 matrix)
|
||||
public FP32Matrix3x2(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r2c1;
|
||||
|
|
@ -91,7 +91,7 @@ namespace BGC
|
|||
this.r2c3 = 0.0f;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Matrix3x2 matrix)
|
||||
public void SetValues(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -102,7 +102,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Matrix3x2 matrix)
|
||||
public void SetValues(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r1c2;
|
||||
|
|
@ -113,7 +113,7 @@ namespace BGC
|
|||
this.r2c3 = (float) matrix.r2c3;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F32Matrix2x3 matrix)
|
||||
public void SetTransposed(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -124,7 +124,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F64Matrix2x3 matrix)
|
||||
public void SetTransposed(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = (float) matrix.r1c1;
|
||||
this.r1c2 = (float) matrix.r2c1;
|
||||
|
|
@ -167,7 +167,7 @@ namespace BGC
|
|||
this.r2c3 = r2;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F32Matrix3x2 matrix, float scale)
|
||||
public void AppendScaled(in FP32Matrix3x2 matrix, float scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1 * scale;
|
||||
this.r1c2 += matrix.r1c2 * scale;
|
||||
|
|
@ -178,7 +178,7 @@ namespace BGC
|
|||
this.r2c3 += matrix.r2c3 * scale;
|
||||
}
|
||||
|
||||
public static void Add(in F32Matrix3x2 matrix1, in F32Matrix3x2 matrix2, out F32Matrix3x2 sum)
|
||||
public static void Add(in FP32Matrix3x2 matrix1, in FP32Matrix3x2 matrix2, out FP32Matrix3x2 sum)
|
||||
{
|
||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -189,7 +189,7 @@ namespace BGC
|
|||
sum.r2c3 = matrix1.r2c3 + matrix2.r2c3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F32Matrix3x2 minuend, in F32Matrix3x2 subtrahend, out F32Matrix3x2 difference)
|
||||
public static void Subtract(in FP32Matrix3x2 minuend, in FP32Matrix3x2 subtrahend, out FP32Matrix3x2 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -200,7 +200,7 @@ namespace BGC
|
|||
difference.r2c3 = minuend.r2c3 - subtrahend.r2c3;
|
||||
}
|
||||
|
||||
public static void Multiply(in F32Matrix3x2 multiplicand, float multiplier, out F32Matrix3x2 product)
|
||||
public static void Multiply(in FP32Matrix3x2 multiplicand, float multiplier, out FP32Matrix3x2 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -211,7 +211,7 @@ namespace BGC
|
|||
product.r2c3 = multiplicand.r2c3 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F32Matrix3x2 dividend, float divisor, out F32Matrix3x2 quotient)
|
||||
public static void Divide(in FP32Matrix3x2 dividend, float divisor, out FP32Matrix3x2 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -222,13 +222,13 @@ namespace BGC
|
|||
quotient.r2c3 = dividend.r2c3 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F32Matrix3x2 matrix, in F32Vector3 vector, out F32Vector2 result)
|
||||
public static void GetRightProduct(in FP32Matrix3x2 matrix, in FP32Vector3 vector, out FP32Vector2 result)
|
||||
{
|
||||
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3;
|
||||
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F32Vector2 vector, in F32Matrix3x2 matrix, out F32Vector3 result)
|
||||
public static void GetLeftProduct(in FP32Vector2 vector, in FP32Matrix3x2 matrix, out FP32Vector3 result)
|
||||
{
|
||||
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1;
|
||||
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2;
|
||||
|
|
@ -23,7 +23,7 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Matrix3x3
|
||||
public struct FP32Matrix3x3
|
||||
{
|
||||
public float r1c1, r1c2, r1c3;
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ namespace BGC
|
|||
|
||||
public float r3c1, r3c2, r3c3;
|
||||
|
||||
public F32Matrix3x3()
|
||||
public FP32Matrix3x3()
|
||||
{
|
||||
this.r1c1 = 0.0f;
|
||||
this.r1c2 = 0.0f;
|
||||
|
|
@ -46,7 +46,7 @@ namespace BGC
|
|||
this.r3c3 = 0.0f;
|
||||
}
|
||||
|
||||
public F32Matrix3x3(float d1, float d2, float d3)
|
||||
public FP32Matrix3x3(float d1, float d2, float d3)
|
||||
{
|
||||
this.r1c1 = d1;
|
||||
this.r1c2 = 0.0f;
|
||||
|
|
@ -61,7 +61,7 @@ namespace BGC
|
|||
this.r3c3 = d3;
|
||||
}
|
||||
|
||||
public F32Matrix3x3(in F32Matrix3x3 matrix)
|
||||
public FP32Matrix3x3(in FP32Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -76,7 +76,7 @@ namespace BGC
|
|||
this.r3c3 = matrix.r3c3;
|
||||
}
|
||||
|
||||
public F32Matrix3x3(in F64Matrix3x3 matrix)
|
||||
public FP32Matrix3x3(in FP64Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = (float)matrix.r1c1;
|
||||
this.r1c2 = (float)matrix.r1c2;
|
||||
|
|
@ -101,7 +101,7 @@ namespace BGC
|
|||
public readonly bool IsSingular()
|
||||
{
|
||||
float determinant = this.GetDeterminant();
|
||||
return -F32Utility.EPSYLON <= determinant && determinant <= F32Utility.EPSYLON;
|
||||
return -FP32Utility.EPSYLON <= determinant && determinant <= FP32Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Transpose()
|
||||
|
|
@ -115,7 +115,7 @@ namespace BGC
|
|||
{
|
||||
float determinant = this.GetDeterminant();
|
||||
|
||||
if (-F32Utility.EPSYLON <= determinant && determinant <= F32Utility.EPSYLON) {
|
||||
if (-FP32Utility.EPSYLON <= determinant && determinant <= FP32Utility.EPSYLON) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ namespace BGC
|
|||
this.r2c3 = d3;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Matrix3x3 matrix)
|
||||
public void SetValues(in FP32Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -206,7 +206,7 @@ namespace BGC
|
|||
this.r3c3 = matrix.r3c3;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Matrix3x3 matrix)
|
||||
public void SetValues(in FP64Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = (float)matrix.r1c1;
|
||||
this.r1c2 = (float)matrix.r1c2;
|
||||
|
|
@ -221,7 +221,7 @@ namespace BGC
|
|||
this.r3c3 = (float)matrix.r3c3;
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F32Matrix3x3 matrix)
|
||||
public void SetTransposedOf(in FP32Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r2c2 = matrix.r2c2;
|
||||
|
|
@ -232,7 +232,7 @@ namespace BGC
|
|||
(this.r2c3, this.r3c2) = (matrix.r3c2, matrix.r2c3);
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F64Matrix3x3 matrix)
|
||||
public void SetTransposedOf(in FP64Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = (float)matrix.r1c1;
|
||||
this.r1c2 = (float)matrix.r2c1;
|
||||
|
|
@ -247,11 +247,11 @@ namespace BGC
|
|||
this.r3c3 = (float)matrix.r3c3;
|
||||
}
|
||||
|
||||
public bool SetInvertedOf(in F32Matrix3x3 matrix)
|
||||
public bool SetInvertedOf(in FP32Matrix3x3 matrix)
|
||||
{
|
||||
float determinant = matrix.GetDeterminant();
|
||||
|
||||
if (-F32Utility.EPSYLON <= determinant && determinant <= F32Utility.EPSYLON) {
|
||||
if (-FP32Utility.EPSYLON <= determinant && determinant <= FP32Utility.EPSYLON) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ namespace BGC
|
|||
this.r3c3 = r3;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F32Matrix3x3 matrix, float scale)
|
||||
public void AppendScaled(in FP32Matrix3x3 matrix, float scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1* scale;
|
||||
this.r1c2 += matrix.r1c2* scale;
|
||||
|
|
@ -339,7 +339,7 @@ namespace BGC
|
|||
this.r3c3 += matrix.r3c3* scale;
|
||||
}
|
||||
|
||||
public static void Add(in F32Matrix3x3 matrix1, in F32Matrix3x3 matrix2, out F32Matrix3x3 sum)
|
||||
public static void Add(in FP32Matrix3x3 matrix1, in FP32Matrix3x3 matrix2, out FP32Matrix3x3 sum)
|
||||
{
|
||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -354,7 +354,7 @@ namespace BGC
|
|||
sum.r3c3 = matrix1.r3c3 + matrix2.r3c3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F32Matrix3x3 minuend, in F32Matrix3x3 subtrahend, out F32Matrix3x3 difference)
|
||||
public static void Subtract(in FP32Matrix3x3 minuend, in FP32Matrix3x3 subtrahend, out FP32Matrix3x3 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -369,7 +369,7 @@ namespace BGC
|
|||
difference.r3c3 = minuend.r3c3 - subtrahend.r3c3;
|
||||
}
|
||||
|
||||
public static void Multiply(in F32Matrix3x3 multiplicand, float multiplier, out F32Matrix3x3 product)
|
||||
public static void Multiply(in FP32Matrix3x3 multiplicand, float multiplier, out FP32Matrix3x3 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -384,7 +384,7 @@ namespace BGC
|
|||
product.r3c3 = multiplicand.r3c3 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F32Matrix3x3 dividend, float divisor, out F32Matrix3x3 quotient)
|
||||
public static void Divide(in FP32Matrix3x3 dividend, float divisor, out FP32Matrix3x3 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -399,7 +399,7 @@ namespace BGC
|
|||
quotient.r3c3 = dividend.r3c3 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F32Matrix3x3 matrix, in F32Vector3 vector, out F32Vector3 result)
|
||||
public static void GetRightProduct(in FP32Matrix3x3 matrix, in FP32Vector3 vector, out FP32Vector3 result)
|
||||
{
|
||||
float x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3;
|
||||
float x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3;
|
||||
|
|
@ -410,7 +410,7 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F32Vector3 vector, in F32Matrix3x3 matrix, out F32Vector3 result)
|
||||
public static void GetLeftProduct(in FP32Vector3 vector, in FP32Matrix3x3 matrix, out FP32Vector3 result)
|
||||
{
|
||||
float x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1;
|
||||
float x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2;
|
||||
|
|
@ -421,7 +421,7 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public static void LoadZero(out F32Matrix3x3 matrix)
|
||||
public static void LoadZero(out FP32Matrix3x3 matrix)
|
||||
{
|
||||
matrix.r1c1 = 0.0f;
|
||||
matrix.r1c2 = 0.0f;
|
||||
|
|
@ -436,7 +436,7 @@ namespace BGC
|
|||
matrix.r3c3 = 0.0f;
|
||||
}
|
||||
|
||||
public static void LoadIdentity(out F32Matrix3x3 matrix)
|
||||
public static void LoadIdentity(out FP32Matrix3x3 matrix)
|
||||
{
|
||||
matrix.r1c1 = 1.0f;
|
||||
matrix.r1c2 = 0.0f;
|
||||
|
|
@ -451,7 +451,7 @@ namespace BGC
|
|||
matrix.r3c3 = 1.0f;
|
||||
}
|
||||
|
||||
public static void LoadDiagonal(float d1, float d2, float d3, out F32Matrix3x3 matrix)
|
||||
public static void LoadDiagonal(float d1, float d2, float d3, out FP32Matrix3x3 matrix)
|
||||
{
|
||||
matrix.r1c1 = d1;
|
||||
matrix.r1c2 = 0.0f;
|
||||
|
|
@ -22,9 +22,9 @@ using System;
|
|||
*/
|
||||
namespace BGC
|
||||
{
|
||||
public class F32MatrixProduct
|
||||
public class FP32MatrixProduct
|
||||
{
|
||||
public static void Get2x2At2x2(in F32Matrix2x2 left, in F32Matrix2x2 right, out F32Matrix2x2 product)
|
||||
public static void Get2x2At2x2(in FP32Matrix2x2 left, in FP32Matrix2x2 right, out FP32Matrix2x2 product)
|
||||
{
|
||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -39,7 +39,7 @@ namespace BGC
|
|||
product.r2c2 = r2c2;
|
||||
}
|
||||
|
||||
public static void Get2x2At3x2(in F32Matrix2x2 left, in F32Matrix3x2 right, out F32Matrix3x2 product)
|
||||
public static void Get2x2At3x2(in FP32Matrix2x2 left, in FP32Matrix3x2 right, out FP32Matrix3x2 product)
|
||||
{
|
||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -58,7 +58,7 @@ namespace BGC
|
|||
product.r2c3 = r2c3;
|
||||
}
|
||||
|
||||
public static void Get2x3At2x2(in F32Matrix2x3 left, in F32Matrix2x2 right, out F32Matrix2x3 product)
|
||||
public static void Get2x3At2x2(in FP32Matrix2x3 left, in FP32Matrix2x2 right, out FP32Matrix2x3 product)
|
||||
{
|
||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -79,7 +79,7 @@ namespace BGC
|
|||
product.r3c2 = r3c2;
|
||||
}
|
||||
|
||||
public static void Get2x3At3x2(in F32Matrix2x3 left, in F32Matrix3x2 right, out F32Matrix3x3 product)
|
||||
public static void Get2x3At3x2(in FP32Matrix2x3 left, in FP32Matrix3x2 right, out FP32Matrix3x3 product)
|
||||
{
|
||||
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -94,7 +94,7 @@ namespace BGC
|
|||
product.r3c3 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c3;
|
||||
}
|
||||
|
||||
public static void Get3x2At3x3(in F32Matrix3x2 left, in F32Matrix3x3 right, out F32Matrix3x2 product)
|
||||
public static void Get3x2At3x3(in FP32Matrix3x2 left, in FP32Matrix3x3 right, out FP32Matrix3x2 product)
|
||||
{
|
||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -113,7 +113,7 @@ namespace BGC
|
|||
product.r2c3 = r2c3;
|
||||
}
|
||||
|
||||
public static void Get3x2At2x3(in F32Matrix3x2 left, in F32Matrix2x3 right, out F32Matrix2x2 product)
|
||||
public static void Get3x2At2x3(in FP32Matrix3x2 left, in FP32Matrix2x3 right, out FP32Matrix2x2 product)
|
||||
{
|
||||
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -122,7 +122,7 @@ namespace BGC
|
|||
product.r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2 + left.r2c3 * right.r3c2;
|
||||
}
|
||||
|
||||
public static void Get3x3At2x3(in F32Matrix3x3 left, in F32Matrix2x3 right, out F32Matrix2x3 product)
|
||||
public static void Get3x3At2x3(in FP32Matrix3x3 left, in FP32Matrix2x3 right, out FP32Matrix2x3 product)
|
||||
{
|
||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -143,7 +143,7 @@ namespace BGC
|
|||
product.r3c2 = r3c2;
|
||||
}
|
||||
|
||||
public static void Get3x3At3x3(in F32Matrix3x3 left, in F32Matrix3x3 right, out F32Matrix3x3 product)
|
||||
public static void Get3x3At3x3(in FP32Matrix3x3 left, in FP32Matrix3x3 right, out FP32Matrix3x3 product)
|
||||
{
|
||||
float r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
float r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Quaternion
|
||||
public struct FP32Quaternion
|
||||
{
|
||||
public float s0, x1, x2, x3;
|
||||
|
||||
public F32Quaternion(float s0, float x1, float x2, float x3)
|
||||
public FP32Quaternion(float s0, float x1, float x2, float x3)
|
||||
{
|
||||
this.s0 = s0;
|
||||
this.x1 = x1;
|
||||
|
|
@ -14,7 +14,7 @@ namespace BGC
|
|||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public F32Quaternion(in F32Quaternion quaternion)
|
||||
public FP32Quaternion(in FP32Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = quaternion.x1;
|
||||
|
|
@ -22,7 +22,7 @@ namespace BGC
|
|||
this.x3 = quaternion.x3;
|
||||
}
|
||||
|
||||
public F32Quaternion(in F64Quaternion quaternion)
|
||||
public FP32Quaternion(in FP64Quaternion quaternion)
|
||||
{
|
||||
this.s0 = (float)quaternion.s0;
|
||||
this.x1 = (float)quaternion.x1;
|
||||
|
|
@ -53,7 +53,7 @@ namespace BGC
|
|||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Quaternion quaternion)
|
||||
public void SetValues(in FP32Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = quaternion.x1;
|
||||
|
|
@ -61,7 +61,7 @@ namespace BGC
|
|||
this.x3 = quaternion.x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Quaternion quaternion)
|
||||
public void SetValues(in FP64Quaternion quaternion)
|
||||
{
|
||||
this.s0 = (float)quaternion.s0;
|
||||
this.x1 = (float)quaternion.x1;
|
||||
|
|
@ -69,7 +69,7 @@ namespace BGC
|
|||
this.x3 = (float)quaternion.x3;
|
||||
}
|
||||
|
||||
public void SetConjugateOf(in F32Quaternion quaternion)
|
||||
public void SetConjugateOf(in FP32Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = -quaternion.x1;
|
||||
|
|
@ -77,7 +77,7 @@ namespace BGC
|
|||
this.x3 = -quaternion.x3;
|
||||
}
|
||||
|
||||
public readonly void MakeRotationMatrix(out F32Matrix3x3 matrix)
|
||||
public readonly void MakeRotationMatrix(out FP32Matrix3x3 matrix)
|
||||
{
|
||||
float s0s0 = this.s0 * this.s0;
|
||||
float x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -86,16 +86,16 @@ namespace BGC
|
|||
|
||||
float squareModule = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-F32Utility.EPSYLON <= squareModule && squareModule <= F32Utility.EPSYLON)
|
||||
if (-FP32Utility.EPSYLON <= squareModule && squareModule <= FP32Utility.EPSYLON)
|
||||
{
|
||||
F32Matrix3x3.LoadIdentity(out matrix);
|
||||
FP32Matrix3x3.LoadIdentity(out matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
float corrector1;
|
||||
float corrector2;
|
||||
|
||||
if (1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + F32Utility.TWO_EPSYLON) {
|
||||
if (1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + FP32Utility.TWO_EPSYLON) {
|
||||
corrector1 = 2.0f - squareModule;
|
||||
corrector2 = 2.0f * corrector1;
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ namespace BGC
|
|||
matrix.r1c3 = corrector2 * (x1x3 + s0x2);
|
||||
}
|
||||
|
||||
public readonly void MakeReverseMatrix(out F32Matrix3x3 matrix)
|
||||
public readonly void MakeReverseMatrix(out FP32Matrix3x3 matrix)
|
||||
{
|
||||
float s0s0 = this.s0 * this.s0;
|
||||
float x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -133,16 +133,16 @@ namespace BGC
|
|||
|
||||
float squareModule = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-F32Utility.EPSYLON <= squareModule && squareModule <= F32Utility.EPSYLON)
|
||||
if (-FP32Utility.EPSYLON <= squareModule && squareModule <= FP32Utility.EPSYLON)
|
||||
{
|
||||
F32Matrix3x3.LoadIdentity(out matrix);
|
||||
FP32Matrix3x3.LoadIdentity(out matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
float corrector1;
|
||||
float corrector2;
|
||||
|
||||
if (1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + F32Utility.TWO_EPSYLON) {
|
||||
if (1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + FP32Utility.TWO_EPSYLON) {
|
||||
corrector1 = 2.0f - squareModule;
|
||||
corrector2 = 2.0f * corrector1;
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ namespace BGC
|
|||
matrix.r1c3 = corrector2 * (x1x3 - s0x2);
|
||||
}
|
||||
|
||||
public static void Add(in F32Quaternion quaternion1, in F32Quaternion quaternion2, out F32Quaternion sum)
|
||||
public static void Add(in FP32Quaternion quaternion1, in FP32Quaternion quaternion2, out FP32Quaternion sum)
|
||||
{
|
||||
sum.s0 = quaternion1.s0 + quaternion2.s0;
|
||||
sum.x1 = quaternion1.x1 + quaternion2.x1;
|
||||
|
|
@ -179,7 +179,7 @@ namespace BGC
|
|||
sum.x3 = quaternion1.x3 + quaternion2.x3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F32Quaternion minuend, in F32Quaternion subtrahend, out F32Quaternion difference)
|
||||
public static void Subtract(in FP32Quaternion minuend, in FP32Quaternion subtrahend, out FP32Quaternion difference)
|
||||
{
|
||||
difference.s0 = minuend.s0 - subtrahend.s0;
|
||||
difference.x1 = minuend.x1 - subtrahend.x1;
|
||||
|
|
@ -187,7 +187,7 @@ namespace BGC
|
|||
difference.x3 = minuend.x3 - subtrahend.x3;
|
||||
}
|
||||
|
||||
public static void Multiply(in F32Quaternion left, in F32Quaternion right, out F32Quaternion product)
|
||||
public static void Multiply(in FP32Quaternion left, in FP32Quaternion right, out FP32Quaternion product)
|
||||
{
|
||||
float s0 = (left.s0 * right.s0 - left.x1 * right.x1) - (left.x2 * right.x2 + left.x3 * right.x3);
|
||||
float x1 = (left.x1 * right.s0 + left.s0 * right.x1) - (left.x3 * right.x2 - left.x2 * right.x3);
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F32Radians
|
||||
public class FP32Radians
|
||||
{
|
||||
public const float PI = 3.1415926536f;
|
||||
public const float TWO_PI = 6.2831853072f;
|
||||
|
|
@ -23,13 +23,13 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Rotation3
|
||||
public struct FP32Rotation3
|
||||
{
|
||||
private float angle;
|
||||
|
||||
private F32Vector3 axis;
|
||||
private FP32Vector3 axis;
|
||||
|
||||
public F32Rotation3(F32Rotation3 rotation)
|
||||
public FP32Rotation3(FP32Rotation3 rotation)
|
||||
{
|
||||
this.angle = rotation.angle;
|
||||
this.axis = rotation.axis;
|
||||
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F32Turns
|
||||
public class FP32Turns
|
||||
{
|
||||
public static float ToRadians(float turns)
|
||||
{
|
||||
return turns * F32Radians.TWO_PI;
|
||||
return turns * FP32Radians.TWO_PI;
|
||||
}
|
||||
|
||||
public static float ToDegrees(float turns)
|
||||
|
|
@ -22,7 +22,7 @@ namespace BGC
|
|||
{
|
||||
if (toUnit == AngleUnit.RADIANS)
|
||||
{
|
||||
return turns * F32Radians.TWO_PI;
|
||||
return turns * FP32Radians.TWO_PI;
|
||||
}
|
||||
|
||||
if (toUnit == AngleUnit.DEGREES)
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F32Utility
|
||||
public class FP32Utility
|
||||
{
|
||||
public const float EPSYLON = 5E-7f;
|
||||
public const float TWO_EPSYLON = 1E-6f;
|
||||
|
|
@ -23,26 +23,26 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Vector2
|
||||
public struct FP32Vector2
|
||||
{
|
||||
public static readonly F32Vector2 ZERO = new F32Vector2(0.0f, 0.0f);
|
||||
public static readonly FP32Vector2 ZERO = new FP32Vector2(0.0f, 0.0f);
|
||||
|
||||
public float x1;
|
||||
public float x2;
|
||||
|
||||
public F32Vector2(float x1, float x2)
|
||||
public FP32Vector2(float x1, float x2)
|
||||
{
|
||||
this.x1 = x1;
|
||||
this.x2 = x2;
|
||||
}
|
||||
|
||||
public F32Vector2(in F32Vector2 vector)
|
||||
public FP32Vector2(in FP32Vector2 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
}
|
||||
|
||||
public F32Vector2(in F64Vector2 vector)
|
||||
public FP32Vector2(in FP64Vector2 vector)
|
||||
{
|
||||
this.x1 = (float)vector.x1;
|
||||
this.x2 = (float)vector.x2;
|
||||
|
|
@ -62,12 +62,12 @@ namespace BGC
|
|||
{
|
||||
float squareModule = this.GetSquareModule();
|
||||
|
||||
if (1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + F32Utility.TWO_EPSYLON)
|
||||
if (1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + FP32Utility.TWO_EPSYLON)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (squareModule <= F32Utility.SQUARE_EPSYLON)
|
||||
if (squareModule <= FP32Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
this.Reset();
|
||||
return 0;
|
||||
|
|
@ -89,13 +89,13 @@ namespace BGC
|
|||
|
||||
public readonly bool IsZero()
|
||||
{
|
||||
return this.GetSquareModule() <= F32Utility.SQUARE_EPSYLON;
|
||||
return this.GetSquareModule() <= FP32Utility.SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
public readonly bool IsUnit()
|
||||
{
|
||||
float squareModule = this.GetSquareModule();
|
||||
return 1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= F32Utility.EPSYLON;
|
||||
return 1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= FP32Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
@ -110,31 +110,31 @@ namespace BGC
|
|||
this.x2 = x2;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Vector2 vector)
|
||||
public void SetValues(in FP32Vector2 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Vector2 vector)
|
||||
public void SetValues(in FP64Vector2 vector)
|
||||
{
|
||||
this.x1 = (float)vector.x1;
|
||||
this.x2 = (float)vector.x2;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F32Vector2 vector)
|
||||
public void SetReverseOf(in FP32Vector2 vector)
|
||||
{
|
||||
this.x1 = -vector.x1;
|
||||
this.x2 = -vector.x2;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F64Vector2 vector)
|
||||
public void SetReverseOf(in FP64Vector2 vector)
|
||||
{
|
||||
this.x1 = -(float)vector.x1;
|
||||
this.x2 = -(float)vector.x2;
|
||||
}
|
||||
|
||||
public void AppendScaled(F32Vector2 summand, float scale)
|
||||
public void AppendScaled(FP32Vector2 summand, float scale)
|
||||
{
|
||||
this.x1 += summand.x1 * scale;
|
||||
this.x2 += summand.x2 * scale;
|
||||
|
|
@ -145,84 +145,84 @@ namespace BGC
|
|||
return String.Format("SPVector2({0}, {1})", this.x1, this.x2);
|
||||
}
|
||||
|
||||
public static void Add(in F32Vector2 vector1, in F32Vector2 vector2, out F32Vector2 sum)
|
||||
public static void Add(in FP32Vector2 vector1, in FP32Vector2 vector2, out FP32Vector2 sum)
|
||||
{
|
||||
sum.x1 = vector1.x1 + vector2.x1;
|
||||
sum.x2 = vector1.x2 + vector2.x2;
|
||||
}
|
||||
|
||||
public static void Subtract(in F32Vector2 minuend, in F32Vector2 subtrahend, out F32Vector2 difference)
|
||||
public static void Subtract(in FP32Vector2 minuend, in FP32Vector2 subtrahend, out FP32Vector2 difference)
|
||||
{
|
||||
difference.x1 = minuend.x1 - subtrahend.x1;
|
||||
difference.x2 = minuend.x2 - subtrahend.x2;
|
||||
}
|
||||
|
||||
public static void Muliply(in F32Vector2 multiplicand, float multiplier, out F32Vector2 product)
|
||||
public static void Muliply(in FP32Vector2 multiplicand, float multiplier, out FP32Vector2 product)
|
||||
{
|
||||
product.x1 = multiplicand.x1 * multiplier;
|
||||
product.x2 = multiplicand.x2 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F32Vector2 dividend, float divisor, out F32Vector2 quotient)
|
||||
public static void Divide(in FP32Vector2 dividend, float divisor, out FP32Vector2 quotient)
|
||||
{
|
||||
quotient.x1 = dividend.x1 / divisor;
|
||||
quotient.x2 = dividend.x2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetMean2(in F32Vector2 vector1, in F32Vector2 vector2, out F32Vector2 result)
|
||||
public static void GetMean2(in FP32Vector2 vector1, in FP32Vector2 vector2, out FP32Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1) * 0.5f;
|
||||
result.x2 = (vector1.x2 + vector2.x2) * 0.5f;
|
||||
}
|
||||
|
||||
public static void GetMean3(in F32Vector2 vector1, in F32Vector2 vector2, in F32Vector2 vector3, out F32Vector2 result)
|
||||
public static void GetMean3(in FP32Vector2 vector1, in FP32Vector2 vector2, in FP32Vector2 vector3, out FP32Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * F32Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * F32Utility.ONE_THIRD;
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * FP32Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * FP32Utility.ONE_THIRD;
|
||||
}
|
||||
|
||||
public static float GetScalarProduct(in F32Vector2 vector1, in F32Vector2 vector2)
|
||||
public static float GetScalarProduct(in FP32Vector2 vector1, in FP32Vector2 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x1 + vector1.x2 * vector2.x2;
|
||||
}
|
||||
|
||||
public static float GetCrossProduct(in F32Vector2 vector1, in F32Vector2 vector2)
|
||||
public static float GetCrossProduct(in FP32Vector2 vector1, in FP32Vector2 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x2 - vector1.x2 * vector2.x1;
|
||||
}
|
||||
|
||||
public static float GetAngle(in F32Vector2 vector1, in F32Vector2 vector2, AngleUnit unit)
|
||||
public static float GetAngle(in FP32Vector2 vector1, in FP32Vector2 vector2, AngleUnit unit)
|
||||
{
|
||||
float squareModule1 = vector1.GetSquareModule();
|
||||
|
||||
if (squareModule1 <= F32Utility.SQUARE_EPSYLON)
|
||||
if (squareModule1 <= FP32Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float squareModule2 = vector2.GetSquareModule();
|
||||
|
||||
if (squareModule2 <= F32Utility.SQUARE_EPSYLON)
|
||||
if (squareModule2 <= FP32Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float cosine = F32Vector2.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2);
|
||||
float cosine = FP32Vector2.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2);
|
||||
|
||||
if (1.0f - F32Utility.EPSYLON <= cosine)
|
||||
if (1.0f - FP32Utility.EPSYLON <= cosine)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (cosine <= -(1.0f - F32Utility.EPSYLON))
|
||||
if (cosine <= -(1.0f - FP32Utility.EPSYLON))
|
||||
{
|
||||
return F32Angle.GetHalfCircle(unit);
|
||||
return FP32Angle.GetHalfCircle(unit);
|
||||
}
|
||||
|
||||
return F32Radians.ToUnits(MathF.Acos(cosine), unit);
|
||||
return FP32Radians.ToUnits(MathF.Acos(cosine), unit);
|
||||
}
|
||||
|
||||
public static float GetSquareDistance(in F32Vector2 vector1, in F32Vector2 vector2)
|
||||
public static float GetSquareDistance(in FP32Vector2 vector1, in FP32Vector2 vector2)
|
||||
{
|
||||
float dx1 = vector1.x1 - vector2.x1;
|
||||
float dx2 = vector1.x2 - vector2.x2;
|
||||
|
|
@ -230,29 +230,29 @@ namespace BGC
|
|||
return dx1 * dx1 + dx2 * dx2;
|
||||
}
|
||||
|
||||
public static float GetDistance(in F32Vector2 vector1, in F32Vector2 vector2)
|
||||
public static float GetDistance(in FP32Vector2 vector1, in FP32Vector2 vector2)
|
||||
{
|
||||
return MathF.Sqrt(GetSquareDistance(vector1, vector2));
|
||||
}
|
||||
|
||||
public static bool AreEqual(in F32Vector2 vector1, in F32Vector2 vector2)
|
||||
public static bool AreEqual(in FP32Vector2 vector1, in FP32Vector2 vector2)
|
||||
{
|
||||
float squareModule1 = vector1.GetSquareModule();
|
||||
float squareModule2 = vector2.GetSquareModule();
|
||||
float squareModule3 = GetSquareDistance(vector1, vector2);
|
||||
|
||||
// 2.0f means dimension amount
|
||||
if (squareModule1 < F32Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < F32Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
if (squareModule1 < FP32Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < FP32Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
{
|
||||
return squareModule3 < (2.0f * F32Utility.SQUARE_EPSYLON);
|
||||
return squareModule3 < (2.0f * FP32Utility.SQUARE_EPSYLON);
|
||||
}
|
||||
|
||||
if (squareModule1 <= squareModule2)
|
||||
{
|
||||
return squareModule3 <= (2.0f * F32Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
return squareModule3 <= (2.0f * FP32Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
}
|
||||
|
||||
return squareModule3 <= (2.0f * F32Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
return squareModule3 <= (2.0f * FP32Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,29 +23,29 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Vector3
|
||||
public struct FP32Vector3
|
||||
{
|
||||
public static readonly F32Vector3 ZERO = new F32Vector3(0.0f, 0.0f, 0.0f);
|
||||
public static readonly FP32Vector3 ZERO = new FP32Vector3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
public float x1;
|
||||
public float x2;
|
||||
public float x3;
|
||||
|
||||
public F32Vector3(float x1, float x2, float x3)
|
||||
public FP32Vector3(float x1, float x2, float x3)
|
||||
{
|
||||
this.x1 = x1;
|
||||
this.x2 = x2;
|
||||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public F32Vector3(in F32Vector3 vector)
|
||||
public FP32Vector3(in FP32Vector3 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
this.x3 = vector.x3;
|
||||
}
|
||||
|
||||
public F32Vector3(in F64Vector3 vector)
|
||||
public FP32Vector3(in FP64Vector3 vector)
|
||||
{
|
||||
this.x1 = (float)vector.x1;
|
||||
this.x2 = (float)vector.x2;
|
||||
|
|
@ -66,12 +66,12 @@ namespace BGC
|
|||
{
|
||||
float squareModule = this.GetSquareModule();
|
||||
|
||||
if (1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + F32Utility.TWO_EPSYLON)
|
||||
if (1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + FP32Utility.TWO_EPSYLON)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (squareModule <= F32Utility.SQUARE_EPSYLON)
|
||||
if (squareModule <= FP32Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
this.Reset();
|
||||
return 0;
|
||||
|
|
@ -95,13 +95,13 @@ namespace BGC
|
|||
|
||||
public readonly bool IsZero()
|
||||
{
|
||||
return this.GetSquareModule() <= F32Utility.SQUARE_EPSYLON;
|
||||
return this.GetSquareModule() <= FP32Utility.SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
public readonly bool IsUnit()
|
||||
{
|
||||
float squareModule = this.GetSquareModule();
|
||||
return 1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= F32Utility.EPSYLON;
|
||||
return 1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= FP32Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
@ -118,35 +118,35 @@ namespace BGC
|
|||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Vector3 vector)
|
||||
public void SetValues(in FP64Vector3 vector)
|
||||
{
|
||||
this.x1 = (float)vector.x1;
|
||||
this.x2 = (float)vector.x2;
|
||||
this.x3 = (float)vector.x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Vector3 vector)
|
||||
public void SetValues(in FP32Vector3 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
this.x3 = vector.x3;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F32Vector3 vector)
|
||||
public void SetReverseOf(in FP32Vector3 vector)
|
||||
{
|
||||
this.x1 = -vector.x1;
|
||||
this.x2 = -vector.x2;
|
||||
this.x3 = -vector.x3;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F64Vector3 vector)
|
||||
public void SetReverseOf(in FP64Vector3 vector)
|
||||
{
|
||||
this.x1 = -(float)vector.x1;
|
||||
this.x2 = -(float)vector.x2;
|
||||
this.x3 = -(float)vector.x3;
|
||||
}
|
||||
|
||||
public void AppendScaled(F32Vector3 summand, float scale)
|
||||
public void AppendScaled(FP32Vector3 summand, float scale)
|
||||
{
|
||||
this.x1 += summand.x1 * scale;
|
||||
this.x2 += summand.x2 * scale;
|
||||
|
|
@ -158,54 +158,54 @@ namespace BGC
|
|||
return String.Format("SPVector3({0}, {1}, {2})", this.x1, this.x2, this.x3);
|
||||
}
|
||||
|
||||
public static void Add(in F32Vector3 vector1, in F32Vector3 vector2, out F32Vector3 sum)
|
||||
public static void Add(in FP32Vector3 vector1, in FP32Vector3 vector2, out FP32Vector3 sum)
|
||||
{
|
||||
sum.x1 = vector1.x1 + vector2.x1;
|
||||
sum.x2 = vector1.x2 + vector2.x2;
|
||||
sum.x3 = vector1.x3 + vector2.x3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F32Vector3 minuend, in F32Vector3 subtrahend, out F32Vector3 difference)
|
||||
public static void Subtract(in FP32Vector3 minuend, in FP32Vector3 subtrahend, out FP32Vector3 difference)
|
||||
{
|
||||
difference.x1 = minuend.x1 - subtrahend.x1;
|
||||
difference.x2 = minuend.x2 - subtrahend.x2;
|
||||
difference.x3 = minuend.x3 - subtrahend.x3;
|
||||
}
|
||||
|
||||
public static void Muliply(in F32Vector3 multiplicand, float multiplier, out F32Vector3 product)
|
||||
public static void Muliply(in FP32Vector3 multiplicand, float multiplier, out FP32Vector3 product)
|
||||
{
|
||||
product.x1 = multiplicand.x1 * multiplier;
|
||||
product.x2 = multiplicand.x2 * multiplier;
|
||||
product.x3 = multiplicand.x3 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F32Vector3 dividend, float divisor, out F32Vector3 quotient)
|
||||
public static void Divide(in FP32Vector3 dividend, float divisor, out FP32Vector3 quotient)
|
||||
{
|
||||
quotient.x1 = dividend.x1 / divisor;
|
||||
quotient.x2 = dividend.x2 / divisor;
|
||||
quotient.x3 = dividend.x3 / divisor;
|
||||
}
|
||||
|
||||
public static void GetMean2(in F32Vector3 vector1, in F32Vector3 vector2, out F32Vector3 result)
|
||||
public static void GetMean2(in FP32Vector3 vector1, in FP32Vector3 vector2, out FP32Vector3 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1) * 0.5f;
|
||||
result.x2 = (vector1.x2 + vector2.x2) * 0.5f;
|
||||
result.x3 = (vector1.x3 + vector2.x3) * 0.5f;
|
||||
}
|
||||
|
||||
public static void GetMean3(in F32Vector3 vector1, in F32Vector3 vector2, in F32Vector3 vector3, out F32Vector3 result)
|
||||
public static void GetMean3(in FP32Vector3 vector1, in FP32Vector3 vector2, in FP32Vector3 vector3, out FP32Vector3 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * F32Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * F32Utility.ONE_THIRD;
|
||||
result.x3 = (vector1.x3 + vector2.x3 + vector3.x3) * F32Utility.ONE_THIRD;
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * FP32Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * FP32Utility.ONE_THIRD;
|
||||
result.x3 = (vector1.x3 + vector2.x3 + vector3.x3) * FP32Utility.ONE_THIRD;
|
||||
}
|
||||
|
||||
public static float GetScalarProduct(in F32Vector3 vector1, in F32Vector3 vector2)
|
||||
public static float GetScalarProduct(in FP32Vector3 vector1, in FP32Vector3 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x1 + vector1.x2 * vector2.x2 + vector1.x3 * vector2.x3;
|
||||
}
|
||||
|
||||
public static void GetCrossProduct(in F32Vector3 vector1, in F32Vector3 vector2, out F32Vector3 result)
|
||||
public static void GetCrossProduct(in FP32Vector3 vector1, in FP32Vector3 vector2, out FP32Vector3 result)
|
||||
{
|
||||
float x1 = vector1.x2 * vector2.x3 - vector1.x3 * vector2.x2;
|
||||
float x2 = vector1.x3 * vector2.x1 - vector1.x1 * vector2.x3;
|
||||
|
|
@ -216,14 +216,14 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public static float GetTripleProduct(in F32Vector3 vector1, in F32Vector3 vector2, in F32Vector3 vector3)
|
||||
public static float GetTripleProduct(in FP32Vector3 vector1, in FP32Vector3 vector2, in FP32Vector3 vector3)
|
||||
{
|
||||
return vector1.x1 * (vector2.x2 * vector3.x3 - vector2.x3 * vector3.x2)
|
||||
+ vector1.x2 * (vector2.x3 * vector3.x1 - vector2.x1 * vector3.x3)
|
||||
+ vector1.x3 * (vector2.x1 * vector3.x2 - vector2.x2 * vector3.x1);
|
||||
}
|
||||
|
||||
public static void GetDoubleCrossProduct(in F32Vector3 vector1, in F32Vector3 vector2, in F32Vector3 vector3, out F32Vector3 result)
|
||||
public static void GetDoubleCrossProduct(in FP32Vector3 vector1, in FP32Vector3 vector2, in FP32Vector3 vector3, out FP32Vector3 result)
|
||||
{
|
||||
// [a x [b x c]] = b * (a, c) - c * (a, b)
|
||||
float ac = GetScalarProduct(vector1, vector3);
|
||||
|
|
@ -234,38 +234,38 @@ namespace BGC
|
|||
result.x3 = ac * vector2.x3 - ab * vector3.x3;
|
||||
}
|
||||
|
||||
public static float GetAngle(in F32Vector3 vector1, in F32Vector3 vector2, AngleUnit unit)
|
||||
public static float GetAngle(in FP32Vector3 vector1, in FP32Vector3 vector2, AngleUnit unit)
|
||||
{
|
||||
float squareModule1 = vector1.GetSquareModule();
|
||||
|
||||
if (squareModule1 <= F32Utility.SQUARE_EPSYLON)
|
||||
if (squareModule1 <= FP32Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float squareModule2 = vector2.GetSquareModule();
|
||||
|
||||
if (squareModule2 <= F32Utility.SQUARE_EPSYLON)
|
||||
if (squareModule2 <= FP32Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
float cosine = F32Vector3.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2);
|
||||
float cosine = FP32Vector3.GetScalarProduct(vector1, vector2) / MathF.Sqrt(squareModule1 * squareModule2);
|
||||
|
||||
if (1.0f - F32Utility.EPSYLON <= cosine)
|
||||
if (1.0f - FP32Utility.EPSYLON <= cosine)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (cosine <= -(1.0f - F32Utility.EPSYLON))
|
||||
if (cosine <= -(1.0f - FP32Utility.EPSYLON))
|
||||
{
|
||||
return F32Angle.GetHalfCircle(unit);
|
||||
return FP32Angle.GetHalfCircle(unit);
|
||||
}
|
||||
|
||||
return F32Radians.ToUnits(MathF.Acos(cosine), unit);
|
||||
return FP32Radians.ToUnits(MathF.Acos(cosine), unit);
|
||||
}
|
||||
|
||||
public static float GetSquareDistance(in F32Vector3 vector1, in F32Vector3 vector2)
|
||||
public static float GetSquareDistance(in FP32Vector3 vector1, in FP32Vector3 vector2)
|
||||
{
|
||||
float dx1 = vector1.x1 - vector2.x1;
|
||||
float dx2 = vector1.x2 - vector2.x2;
|
||||
|
|
@ -274,29 +274,29 @@ namespace BGC
|
|||
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
|
||||
}
|
||||
|
||||
public static float GetDistance(in F32Vector3 vector1, in F32Vector3 vector2)
|
||||
public static float GetDistance(in FP32Vector3 vector1, in FP32Vector3 vector2)
|
||||
{
|
||||
return MathF.Sqrt(GetSquareDistance(vector1, vector2));
|
||||
}
|
||||
|
||||
public static bool AreEqual(in F32Vector3 vector1, in F32Vector3 vector2)
|
||||
public static bool AreEqual(in FP32Vector3 vector1, in FP32Vector3 vector2)
|
||||
{
|
||||
float squareModule1 = vector1.GetSquareModule();
|
||||
float squareModule2 = vector2.GetSquareModule();
|
||||
float squareModule3 = GetSquareDistance(vector1, vector2);
|
||||
|
||||
// 3.0f means dimension amount
|
||||
if (squareModule1 < F32Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < F32Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
if (squareModule1 < FP32Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < FP32Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
{
|
||||
return squareModule3 < (3.0f * F32Utility.SQUARE_EPSYLON);
|
||||
return squareModule3 < (3.0f * FP32Utility.SQUARE_EPSYLON);
|
||||
}
|
||||
|
||||
if (squareModule1 <= squareModule2)
|
||||
{
|
||||
return squareModule3 <= (3.0f * F32Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
return squareModule3 <= (3.0f * FP32Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
}
|
||||
|
||||
return squareModule3 <= (3.0f * F32Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
return squareModule3 <= (3.0f * FP32Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,14 +21,14 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F32Versor
|
||||
public struct FP32Versor
|
||||
{
|
||||
private float s0;
|
||||
private float x1;
|
||||
private float x2;
|
||||
private float x3;
|
||||
|
||||
public F32Versor()
|
||||
public FP32Versor()
|
||||
{
|
||||
this.s0 = 1.0f;
|
||||
this.x1 = 0.0f;
|
||||
|
|
@ -36,12 +36,12 @@ namespace BGC
|
|||
this.x3 = 0.0f;
|
||||
}
|
||||
|
||||
public F32Versor(float s0, float x1, float x2, float x3)
|
||||
public FP32Versor(float s0, float x1, float x2, float x3)
|
||||
{
|
||||
LoadValues(s0, x1, x2, x3, out this);
|
||||
}
|
||||
|
||||
public F32Versor(in F32Versor versor)
|
||||
public FP32Versor(in FP32Versor versor)
|
||||
{
|
||||
this.s0 = versor.s0;
|
||||
this.x1 = versor.x1;
|
||||
|
|
@ -49,7 +49,7 @@ namespace BGC
|
|||
this.x3 = versor.x3;
|
||||
}
|
||||
|
||||
public F32Versor(in F64Versor versor)
|
||||
public FP32Versor(in FP64Versor versor)
|
||||
{
|
||||
this.s0 = (float)versor.GetScalar();
|
||||
this.x1 = (float)versor.GetX1();
|
||||
|
|
@ -79,7 +79,7 @@ namespace BGC
|
|||
|
||||
public readonly bool IsIdle()
|
||||
{
|
||||
return this.s0 <= -(1.0f - F32Utility.EPSYLON) || (1.0f - F32Utility.EPSYLON) <= this.s0;
|
||||
return this.s0 <= -(1.0f - FP32Utility.EPSYLON) || (1.0f - FP32Utility.EPSYLON) <= this.s0;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
@ -99,19 +99,19 @@ namespace BGC
|
|||
|
||||
public readonly float GetAngle(AngleUnit unit)
|
||||
{
|
||||
if (this.s0 <= -(1.0f - F32Utility.TWO_EPSYLON) || 1.0f - F32Utility.TWO_EPSYLON <= this.s0) {
|
||||
if (this.s0 <= -(1.0f - FP32Utility.TWO_EPSYLON) || 1.0f - FP32Utility.TWO_EPSYLON <= this.s0) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (-F32Utility.EPSYLON <= this.s0 && this.s0 <= F32Utility.EPSYLON)
|
||||
if (-FP32Utility.EPSYLON <= this.s0 && this.s0 <= FP32Utility.EPSYLON)
|
||||
{
|
||||
return F32Angle.GetHalfCircle(unit);
|
||||
return FP32Angle.GetHalfCircle(unit);
|
||||
}
|
||||
|
||||
return F32Radians.ToUnits(2.0f * MathF.Acos(s0), unit);
|
||||
return FP32Radians.ToUnits(2.0f * MathF.Acos(s0), unit);
|
||||
}
|
||||
|
||||
public readonly void MakeRotationMatrix(out F32Matrix3x3 matrix)
|
||||
public readonly void MakeRotationMatrix(out FP32Matrix3x3 matrix)
|
||||
{
|
||||
float s0s0 = this.s0 * this.s0;
|
||||
float x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -139,7 +139,7 @@ namespace BGC
|
|||
matrix.r1c3 = x1x3 + s0x2;
|
||||
}
|
||||
|
||||
public readonly void MakeReverseMatrix(out F32Matrix3x3 matrix)
|
||||
public readonly void MakeReverseMatrix(out FP32Matrix3x3 matrix)
|
||||
{
|
||||
float s0s0 = this.s0 * this.s0;
|
||||
float x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -176,9 +176,9 @@ namespace BGC
|
|||
|
||||
float squareModule = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + F32Utility.TWO_EPSYLON)
|
||||
if (1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + FP32Utility.TWO_EPSYLON)
|
||||
{
|
||||
if (-1.0f + F32Utility.EPSYLON < s0)
|
||||
if (-1.0f + FP32Utility.EPSYLON < s0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ namespace BGC
|
|||
this.Normalize(squareModule);
|
||||
}
|
||||
|
||||
public void SetValues(in F32Versor versor)
|
||||
public void SetValues(in FP32Versor versor)
|
||||
{
|
||||
this.s0 = versor.s0;
|
||||
this.x1 = versor.x1;
|
||||
|
|
@ -198,7 +198,7 @@ namespace BGC
|
|||
this.x3 = versor.x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Versor versor)
|
||||
public void SetValues(in FP64Versor versor)
|
||||
{
|
||||
this.s0 = (float) versor.GetScalar();
|
||||
this.x1 = (float) versor.GetX1();
|
||||
|
|
@ -206,7 +206,7 @@ namespace BGC
|
|||
this.x3 = (float) versor.GetX3();
|
||||
}
|
||||
|
||||
public void SetInverted(in F32Versor versor)
|
||||
public void SetInverted(in FP32Versor versor)
|
||||
{
|
||||
this.s0 = versor.s0;
|
||||
this.x1 = -versor.x1;
|
||||
|
|
@ -214,7 +214,7 @@ namespace BGC
|
|||
this.x3 = -versor.x3;
|
||||
}
|
||||
|
||||
public void SetInverted(in F64Versor versor)
|
||||
public void SetInverted(in FP64Versor versor)
|
||||
{
|
||||
this.s0 = (float) versor.GetScalar();
|
||||
this.x1 = (float) -versor.GetX1();
|
||||
|
|
@ -222,7 +222,7 @@ namespace BGC
|
|||
this.x3 = (float) -versor.GetX3();
|
||||
}
|
||||
|
||||
public readonly void Turn(in F32Vector3 vector, out F32Vector3 result)
|
||||
public readonly void Turn(in FP32Vector3 vector, out FP32Vector3 result)
|
||||
{
|
||||
float tx1 = 2.0f * (this.x2 * vector.x3 - this.x3 * vector.x2);
|
||||
float tx2 = 2.0f * (this.x3 * vector.x1 - this.x1 * vector.x3);
|
||||
|
|
@ -237,7 +237,7 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public readonly void TurnBack(in F32Vector3 vector, out F32Vector3 result)
|
||||
public readonly void TurnBack(in FP32Vector3 vector, out FP32Vector3 result)
|
||||
{
|
||||
float tx1 = 2.0f * (this.x2 * vector.x3 - this.x3 * vector.x2);
|
||||
float tx2 = 2.0f * (this.x3 * vector.x1 - this.x1 * vector.x3);
|
||||
|
|
@ -254,7 +254,7 @@ namespace BGC
|
|||
|
||||
private void Normalize(float squareModule)
|
||||
{
|
||||
if (squareModule <= F32Utility.SQUARE_EPSYLON || (this.x1 * this.x1 + this.x2 * this.x2 + this.x3 * this.x3) <= F32Utility.SQUARE_EPSYLON * squareModule)
|
||||
if (squareModule <= FP32Utility.SQUARE_EPSYLON || (this.x1 * this.x1 + this.x2 * this.x2 + this.x3 * this.x3) <= FP32Utility.SQUARE_EPSYLON * squareModule)
|
||||
{
|
||||
this.Reset();
|
||||
return;
|
||||
|
|
@ -268,7 +268,7 @@ namespace BGC
|
|||
this.x3 /= module;
|
||||
}
|
||||
|
||||
public static void Combine(in F32Versor second, in F32Versor first, out F32Versor result)
|
||||
public static void Combine(in FP32Versor second, in FP32Versor first, out FP32Versor result)
|
||||
{
|
||||
float s0 = (second.s0 * first.s0 - second.x1 * first.x1) - (second.x2 * first.x2 + second.x3 * first.x3);
|
||||
float x1 = (second.x1 * first.s0 + second.s0 * first.x1) - (second.x3 * first.x2 - second.x2 * first.x3);
|
||||
|
|
@ -282,13 +282,13 @@ namespace BGC
|
|||
result.x2 = x2;
|
||||
result.x3 = x3;
|
||||
|
||||
if (squareModule < 1.0f - F32Utility.TWO_EPSYLON || 1.0f + F32Utility.TWO_EPSYLON < squareModule)
|
||||
if (squareModule < 1.0f - FP32Utility.TWO_EPSYLON || 1.0f + FP32Utility.TWO_EPSYLON < squareModule)
|
||||
{
|
||||
result.Normalize(squareModule);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadIdle(out F32Versor versor)
|
||||
public static void LoadIdle(out FP32Versor versor)
|
||||
{
|
||||
versor.s0 = 1.0f;
|
||||
versor.x1 = 0.0f;
|
||||
|
|
@ -296,7 +296,7 @@ namespace BGC
|
|||
versor.x3 = 0.0f;
|
||||
}
|
||||
|
||||
public static void LoadValues(float s0, float x1, float x2, float x3, out F32Versor versor)
|
||||
public static void LoadValues(float s0, float x1, float x2, float x3, out FP32Versor versor)
|
||||
{
|
||||
versor.s0 = s0;
|
||||
versor.x1 = x1;
|
||||
|
|
@ -305,9 +305,9 @@ namespace BGC
|
|||
|
||||
float squareModule = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0f - F32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + F32Utility.TWO_EPSYLON)
|
||||
if (1.0f - FP32Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0f + FP32Utility.TWO_EPSYLON)
|
||||
{
|
||||
if (-1.0f + F32Utility.EPSYLON < s0)
|
||||
if (-1.0f + FP32Utility.EPSYLON < s0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -23,18 +23,18 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public static class F64Angle
|
||||
public static class FP64Angle
|
||||
{
|
||||
public static double ToRadians(double angle, AngleUnit unit)
|
||||
{
|
||||
if (unit == AngleUnit.DEGREES)
|
||||
{
|
||||
return angle * F64Degrees.RADIANS_IN_DEGREE;
|
||||
return angle * FP64Degrees.RADIANS_IN_DEGREE;
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.TURNS)
|
||||
{
|
||||
return angle * F64Radians.TWO_PI;
|
||||
return angle * FP64Radians.TWO_PI;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -44,7 +44,7 @@ namespace BGC
|
|||
{
|
||||
if (unit == AngleUnit.RADIANS)
|
||||
{
|
||||
return angle * F64Radians.DEGREES_IN_RADIAN;
|
||||
return angle * FP64Radians.DEGREES_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.TURNS)
|
||||
|
|
@ -59,12 +59,12 @@ namespace BGC
|
|||
{
|
||||
if (unit == AngleUnit.RADIANS)
|
||||
{
|
||||
return angle * F64Radians.TURNS_IN_RADIAN;
|
||||
return angle * FP64Radians.TURNS_IN_RADIAN;
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.DEGREES)
|
||||
{
|
||||
return angle * F64Degrees.TURNS_IN_DEGREE;
|
||||
return angle * FP64Degrees.TURNS_IN_DEGREE;
|
||||
}
|
||||
|
||||
return angle;
|
||||
|
|
@ -82,7 +82,7 @@ namespace BGC
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
return F64Radians.TWO_PI;
|
||||
return FP64Radians.TWO_PI;
|
||||
}
|
||||
|
||||
public static double GetHalfCircle(AngleUnit unit)
|
||||
|
|
@ -97,7 +97,7 @@ namespace BGC
|
|||
return 0.5;
|
||||
}
|
||||
|
||||
return F64Radians.PI;
|
||||
return FP64Radians.PI;
|
||||
}
|
||||
|
||||
public static double GetQuarterCircle(AngleUnit unit)
|
||||
|
|
@ -112,22 +112,22 @@ namespace BGC
|
|||
return 0.25;
|
||||
}
|
||||
|
||||
return F64Radians.HALF_OF_PI;
|
||||
return FP64Radians.HALF_OF_PI;
|
||||
}
|
||||
|
||||
public static double Normalize(double angle, AngleUnit unit, AngleRange range)
|
||||
{
|
||||
if (unit == AngleUnit.DEGREES)
|
||||
{
|
||||
return F64Degrees.Normalize(angle, range);
|
||||
return FP64Degrees.Normalize(angle, range);
|
||||
}
|
||||
|
||||
if (unit == AngleUnit.TURNS)
|
||||
{
|
||||
return F64Turns.Normalize(angle, range);
|
||||
return FP64Turns.Normalize(angle, range);
|
||||
}
|
||||
|
||||
return F64Radians.Normalize(angle, range);
|
||||
return FP64Radians.Normalize(angle, range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F64Degrees
|
||||
public class FP64Degrees
|
||||
{
|
||||
public const double RADIANS_IN_DEGREE = 1.74532925199432958E-2;
|
||||
public const double TURNS_IN_DEGREE = 2.77777777777777778E-3;
|
||||
|
|
@ -23,13 +23,13 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Matrix2x2
|
||||
public struct FP64Matrix2x2
|
||||
{
|
||||
public double r1c1, r1c2;
|
||||
|
||||
public double r2c1, r2c2;
|
||||
|
||||
public F64Matrix2x2()
|
||||
public FP64Matrix2x2()
|
||||
{
|
||||
this.r1c1 = 0.0;
|
||||
this.r1c2 = 0.0;
|
||||
|
|
@ -38,7 +38,7 @@ namespace BGC
|
|||
this.r2c2 = 0.0;
|
||||
}
|
||||
|
||||
public F64Matrix2x2(double d1, double d2)
|
||||
public FP64Matrix2x2(double d1, double d2)
|
||||
{
|
||||
this.r1c1 = d1;
|
||||
this.r1c2 = 0.0;
|
||||
|
|
@ -47,7 +47,7 @@ namespace BGC
|
|||
this.r2c2 = d2;
|
||||
}
|
||||
|
||||
public F64Matrix2x2(in F64Matrix2x2 matrix)
|
||||
public FP64Matrix2x2(in FP64Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -56,7 +56,7 @@ namespace BGC
|
|||
this.r2c2 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public F64Matrix2x2(in F32Matrix2x2 matrix)
|
||||
public FP64Matrix2x2(in FP32Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -73,7 +73,7 @@ namespace BGC
|
|||
public readonly bool IsSingular()
|
||||
{
|
||||
double determinant = this.GetDeterminant();
|
||||
return -F64Utility.EPSYLON <= determinant && determinant <= F64Utility.EPSYLON;
|
||||
return -FP64Utility.EPSYLON <= determinant && determinant <= FP64Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Transpose()
|
||||
|
|
@ -85,7 +85,7 @@ namespace BGC
|
|||
{
|
||||
double determinant = this.GetDeterminant();
|
||||
|
||||
if (-F64Utility.EPSYLON <= determinant && determinant <= F64Utility.EPSYLON)
|
||||
if (-FP64Utility.EPSYLON <= determinant && determinant <= FP64Utility.EPSYLON)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ namespace BGC
|
|||
this.r2c2 = d2;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Matrix2x2 matrix)
|
||||
public void SetValues(in FP64Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -141,7 +141,7 @@ namespace BGC
|
|||
this.r2c2 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Matrix2x2 matrix)
|
||||
public void SetValues(in FP32Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -150,14 +150,14 @@ namespace BGC
|
|||
this.r2c2 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F64Matrix2x2 matrix)
|
||||
public void SetTransposedOf(in FP64Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r2c2 = matrix.r2c2;
|
||||
(this.r1c2, this.r2c1) = (matrix.r2c1, matrix.r1c2);
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F32Matrix2x2 matrix)
|
||||
public void SetTransposedOf(in FP32Matrix2x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -166,11 +166,11 @@ namespace BGC
|
|||
this.r2c2 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public bool SetInvertedOf(in F64Matrix2x2 matrix)
|
||||
public bool SetInvertedOf(in FP64Matrix2x2 matrix)
|
||||
{
|
||||
double determinant = matrix.GetDeterminant();
|
||||
|
||||
if (-F64Utility.EPSYLON <= determinant && determinant <= F64Utility.EPSYLON)
|
||||
if (-FP64Utility.EPSYLON <= determinant && determinant <= FP64Utility.EPSYLON)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ namespace BGC
|
|||
this.r2c2 = r2;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F64Matrix2x2 matrix, double scale)
|
||||
public void AppendScaled(in FP64Matrix2x2 matrix, double scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1 * scale;
|
||||
this.r1c2 += matrix.r1c2 * scale;
|
||||
|
|
@ -223,7 +223,7 @@ namespace BGC
|
|||
this.r2c2 += matrix.r2c2 * scale;
|
||||
}
|
||||
|
||||
public static void Add(in F64Matrix2x2 matrix1, in F64Matrix2x2 matrix2, out F64Matrix2x2 sum)
|
||||
public static void Add(in FP64Matrix2x2 matrix1, in FP64Matrix2x2 matrix2, out FP64Matrix2x2 sum)
|
||||
{
|
||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -232,7 +232,7 @@ namespace BGC
|
|||
sum.r2c2 = matrix1.r2c2 + matrix2.r2c2;
|
||||
}
|
||||
|
||||
public static void Subtract(in F64Matrix2x2 minuend, in F64Matrix2x2 subtrahend, out F64Matrix2x2 difference)
|
||||
public static void Subtract(in FP64Matrix2x2 minuend, in FP64Matrix2x2 subtrahend, out FP64Matrix2x2 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -241,7 +241,7 @@ namespace BGC
|
|||
difference.r2c2 = minuend.r2c2 - subtrahend.r2c2;
|
||||
}
|
||||
|
||||
public static void Multiply(in F64Matrix2x2 multiplicand, double multiplier, out F64Matrix2x2 product)
|
||||
public static void Multiply(in FP64Matrix2x2 multiplicand, double multiplier, out FP64Matrix2x2 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -250,7 +250,7 @@ namespace BGC
|
|||
product.r2c2 = multiplicand.r2c2 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F64Matrix2x2 dividend, double divisor, out F64Matrix2x2 quotient)
|
||||
public static void Divide(in FP64Matrix2x2 dividend, double divisor, out FP64Matrix2x2 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -259,7 +259,7 @@ namespace BGC
|
|||
quotient.r2c2 = dividend.r2c2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F64Matrix2x2 matrix, in F64Vector2 vector, out F64Vector2 result)
|
||||
public static void GetRightProduct(in FP64Matrix2x2 matrix, in FP64Vector2 vector, out FP64Vector2 result)
|
||||
{
|
||||
double x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2;
|
||||
double x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2;
|
||||
|
|
@ -268,7 +268,7 @@ namespace BGC
|
|||
result.x2 = x2;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F64Vector2 vector, in F64Matrix2x2 matrix, out F64Vector2 result)
|
||||
public static void GetLeftProduct(in FP64Vector2 vector, in FP64Matrix2x2 matrix, out FP64Vector2 result)
|
||||
{
|
||||
double x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1;
|
||||
double x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2;
|
||||
|
|
@ -277,7 +277,7 @@ namespace BGC
|
|||
result.x2 = x2;
|
||||
}
|
||||
|
||||
public static void LoadZero(out F64Matrix2x2 matrix)
|
||||
public static void LoadZero(out FP64Matrix2x2 matrix)
|
||||
{
|
||||
matrix.r1c1 = 0.0;
|
||||
matrix.r1c2 = 0.0;
|
||||
|
|
@ -286,7 +286,7 @@ namespace BGC
|
|||
matrix.r2c2 = 0.0;
|
||||
}
|
||||
|
||||
public static void LoadIdentity(out F64Matrix2x2 matrix)
|
||||
public static void LoadIdentity(out FP64Matrix2x2 matrix)
|
||||
{
|
||||
matrix.r1c1 = 1.0;
|
||||
matrix.r1c2 = 0.0;
|
||||
|
|
@ -295,7 +295,7 @@ namespace BGC
|
|||
matrix.r2c2 = 1.0;
|
||||
}
|
||||
|
||||
public static void LoadDiagonal(double d1, double d2, out F64Matrix2x2 matrix)
|
||||
public static void LoadDiagonal(double d1, double d2, out FP64Matrix2x2 matrix)
|
||||
{
|
||||
matrix.r1c1 = d1;
|
||||
matrix.r1c2 = 0.0;
|
||||
|
|
@ -22,13 +22,13 @@ using System;
|
|||
*/
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Matrix2x3
|
||||
public struct FP64Matrix2x3
|
||||
{
|
||||
public double r1c1, r1c2;
|
||||
public double r2c1, r2c2;
|
||||
public double r3c1, r3c2;
|
||||
|
||||
public F64Matrix2x3()
|
||||
public FP64Matrix2x3()
|
||||
{
|
||||
this.r1c1 = 0.0;
|
||||
this.r1c2 = 0.0;
|
||||
|
|
@ -40,7 +40,7 @@ namespace BGC
|
|||
this.r3c2 = 0.0;
|
||||
}
|
||||
|
||||
public F64Matrix2x3(in F64Matrix2x3 matrix)
|
||||
public FP64Matrix2x3(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -52,7 +52,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public F64Matrix2x3(in F32Matrix2x3 matrix)
|
||||
public FP64Matrix2x3(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -64,7 +64,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public F64Matrix2x3(in F64Matrix3x2 matrix)
|
||||
public FP64Matrix2x3(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -76,7 +76,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public F64Matrix2x3(in F32Matrix3x2 matrix)
|
||||
public FP64Matrix2x3(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -100,7 +100,7 @@ namespace BGC
|
|||
this.r3c2 = 0.0;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Matrix2x3 matrix)
|
||||
public void SetValues(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -112,7 +112,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Matrix2x3 matrix)
|
||||
public void SetValues(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -124,7 +124,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r3c2;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F64Matrix3x2 matrix)
|
||||
public void SetTransposed(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -136,7 +136,7 @@ namespace BGC
|
|||
this.r3c2 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F32Matrix3x2 matrix)
|
||||
public void SetTransposed(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -180,7 +180,7 @@ namespace BGC
|
|||
this.r3c2 = r3;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F64Matrix2x3 matrix, double scale)
|
||||
public void AppendScaled(in FP64Matrix2x3 matrix, double scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1 * scale;
|
||||
this.r1c2 += matrix.r1c2 * scale;
|
||||
|
|
@ -192,7 +192,7 @@ namespace BGC
|
|||
this.r3c2 += matrix.r3c2 * scale;
|
||||
}
|
||||
|
||||
public static void Add(in F64Matrix2x3 matrix1, in F64Matrix2x3 matrix2, out F64Matrix2x3 sum)
|
||||
public static void Add(in FP64Matrix2x3 matrix1, in FP64Matrix2x3 matrix2, out FP64Matrix2x3 sum)
|
||||
{
|
||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -204,7 +204,7 @@ namespace BGC
|
|||
sum.r3c2 = matrix1.r3c2 + matrix2.r3c2;
|
||||
}
|
||||
|
||||
public static void Subtract(in F64Matrix2x3 minuend, in F64Matrix2x3 subtrahend, out F64Matrix2x3 difference)
|
||||
public static void Subtract(in FP64Matrix2x3 minuend, in FP64Matrix2x3 subtrahend, out FP64Matrix2x3 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -216,7 +216,7 @@ namespace BGC
|
|||
difference.r3c2 = minuend.r3c2 - subtrahend.r3c2;
|
||||
}
|
||||
|
||||
public static void Multiply(in F64Matrix2x3 multiplicand, double multiplier, out F64Matrix2x3 product)
|
||||
public static void Multiply(in FP64Matrix2x3 multiplicand, double multiplier, out FP64Matrix2x3 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -228,7 +228,7 @@ namespace BGC
|
|||
product.r3c2 = multiplicand.r3c2 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F64Matrix2x3 dividend, double divisor, out F64Matrix2x3 quotient)
|
||||
public static void Divide(in FP64Matrix2x3 dividend, double divisor, out FP64Matrix2x3 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -240,14 +240,14 @@ namespace BGC
|
|||
quotient.r3c2 = dividend.r3c2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F64Matrix2x3 matrix, in F64Vector2 vector, out F64Vector3 result)
|
||||
public static void GetRightProduct(in FP64Matrix2x3 matrix, in FP64Vector2 vector, out FP64Vector3 result)
|
||||
{
|
||||
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2;
|
||||
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2;
|
||||
result.x3 = matrix.r3c1 * vector.x1 + matrix.r3c2 * vector.x2;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F64Vector3 vector, in F64Matrix2x3 matrix, out F64Vector2 result)
|
||||
public static void GetLeftProduct(in FP64Vector3 vector, in FP64Matrix2x3 matrix, out FP64Vector2 result)
|
||||
{
|
||||
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1;
|
||||
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2;
|
||||
|
|
@ -22,12 +22,12 @@ using System;
|
|||
*/
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Matrix3x2
|
||||
public struct FP64Matrix3x2
|
||||
{
|
||||
public double r1c1, r1c2, r1c3;
|
||||
public double r2c1, r2c2, r2c3;
|
||||
|
||||
public F64Matrix3x2()
|
||||
public FP64Matrix3x2()
|
||||
{
|
||||
this.r1c1 = 0.0;
|
||||
this.r1c2 = 0.0;
|
||||
|
|
@ -38,7 +38,7 @@ namespace BGC
|
|||
this.r2c3 = 0.0;
|
||||
}
|
||||
|
||||
public F64Matrix3x2(in F64Matrix3x2 matrix)
|
||||
public FP64Matrix3x2(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -49,7 +49,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public F64Matrix3x2(in F32Matrix3x2 matrix)
|
||||
public FP64Matrix3x2(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -60,7 +60,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public F64Matrix3x2(in F64Matrix2x3 matrix)
|
||||
public FP64Matrix3x2(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -71,7 +71,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public F64Matrix3x2(in F32Matrix2x3 matrix)
|
||||
public FP64Matrix3x2(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -94,7 +94,7 @@ namespace BGC
|
|||
}
|
||||
|
||||
|
||||
public void SetValues(in F64Matrix3x2 matrix)
|
||||
public void SetValues(in FP64Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -105,7 +105,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Matrix3x2 matrix)
|
||||
public void SetValues(in FP32Matrix3x2 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -116,7 +116,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c3;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F64Matrix2x3 matrix)
|
||||
public void SetTransposed(in FP64Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -127,7 +127,7 @@ namespace BGC
|
|||
this.r2c3 = matrix.r2c2;
|
||||
}
|
||||
|
||||
public void SetTransposed(in F32Matrix2x3 matrix)
|
||||
public void SetTransposed(in FP32Matrix2x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r2c1;
|
||||
|
|
@ -170,7 +170,7 @@ namespace BGC
|
|||
this.r2c3 = r2;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F64Matrix3x2 matrix, double scale)
|
||||
public void AppendScaled(in FP64Matrix3x2 matrix, double scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1 * scale;
|
||||
this.r1c2 += matrix.r1c2 * scale;
|
||||
|
|
@ -181,7 +181,7 @@ namespace BGC
|
|||
this.r2c3 += matrix.r2c3 * scale;
|
||||
}
|
||||
|
||||
public static void Add(in F64Matrix3x2 matrix1, in F64Matrix3x2 matrix2, out F64Matrix3x2 sum)
|
||||
public static void Add(in FP64Matrix3x2 matrix1, in FP64Matrix3x2 matrix2, out FP64Matrix3x2 sum)
|
||||
{
|
||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -192,7 +192,7 @@ namespace BGC
|
|||
sum.r2c3 = matrix1.r2c3 + matrix2.r2c3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F64Matrix3x2 minuend, in F64Matrix3x2 subtrahend, out F64Matrix3x2 difference)
|
||||
public static void Subtract(in FP64Matrix3x2 minuend, in FP64Matrix3x2 subtrahend, out FP64Matrix3x2 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -203,7 +203,7 @@ namespace BGC
|
|||
difference.r2c3 = minuend.r2c3 - subtrahend.r2c3;
|
||||
}
|
||||
|
||||
public static void Multiply(in F64Matrix3x2 multiplicand, double multiplier, out F64Matrix3x2 product)
|
||||
public static void Multiply(in FP64Matrix3x2 multiplicand, double multiplier, out FP64Matrix3x2 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -214,7 +214,7 @@ namespace BGC
|
|||
product.r2c3 = multiplicand.r2c3 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F64Matrix3x2 dividend, double divisor, out F64Matrix3x2 quotient)
|
||||
public static void Divide(in FP64Matrix3x2 dividend, double divisor, out FP64Matrix3x2 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -225,13 +225,13 @@ namespace BGC
|
|||
quotient.r2c3 = dividend.r2c3 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F64Matrix3x2 matrix, in F64Vector3 vector, out F64Vector2 result)
|
||||
public static void GetRightProduct(in FP64Matrix3x2 matrix, in FP64Vector3 vector, out FP64Vector2 result)
|
||||
{
|
||||
result.x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3;
|
||||
result.x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F64Vector2 vector, in F64Matrix3x2 matrix, out F64Vector3 result)
|
||||
public static void GetLeftProduct(in FP64Vector2 vector, in FP64Matrix3x2 matrix, out FP64Vector3 result)
|
||||
{
|
||||
result.x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1;
|
||||
result.x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2;
|
||||
|
|
@ -23,7 +23,7 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Matrix3x3
|
||||
public struct FP64Matrix3x3
|
||||
{
|
||||
public double r1c1, r1c2, r1c3;
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ namespace BGC
|
|||
|
||||
public double r3c1, r3c2, r3c3;
|
||||
|
||||
public F64Matrix3x3()
|
||||
public FP64Matrix3x3()
|
||||
{
|
||||
this.r1c1 = 0.0;
|
||||
this.r1c2 = 0.0;
|
||||
|
|
@ -46,7 +46,7 @@ namespace BGC
|
|||
this.r3c3 = 0.0;
|
||||
}
|
||||
|
||||
public F64Matrix3x3(double d1, double d2, double d3)
|
||||
public FP64Matrix3x3(double d1, double d2, double d3)
|
||||
{
|
||||
this.r1c1 = d1;
|
||||
this.r1c2 = 0.0;
|
||||
|
|
@ -61,7 +61,7 @@ namespace BGC
|
|||
this.r3c3 = d3;
|
||||
}
|
||||
|
||||
public F64Matrix3x3(in F64Matrix3x3 matrix)
|
||||
public FP64Matrix3x3(in FP64Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -76,7 +76,7 @@ namespace BGC
|
|||
this.r3c3 = matrix.r3c3;
|
||||
}
|
||||
|
||||
public F64Matrix3x3(in F32Matrix3x3 matrix)
|
||||
public FP64Matrix3x3(in FP32Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -101,7 +101,7 @@ namespace BGC
|
|||
public readonly bool IsSingular()
|
||||
{
|
||||
double determinant = this.GetDeterminant();
|
||||
return -F64Utility.EPSYLON <= determinant && determinant <= F64Utility.EPSYLON;
|
||||
return -FP64Utility.EPSYLON <= determinant && determinant <= FP64Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Transpose()
|
||||
|
|
@ -115,7 +115,7 @@ namespace BGC
|
|||
{
|
||||
double determinant = this.GetDeterminant();
|
||||
|
||||
if (-F64Utility.EPSYLON <= determinant && determinant <= F64Utility.EPSYLON) {
|
||||
if (-FP64Utility.EPSYLON <= determinant && determinant <= FP64Utility.EPSYLON) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ namespace BGC
|
|||
this.r2c3 = d3;
|
||||
}
|
||||
|
||||
public void SetValues(F64Matrix3x3 matrix)
|
||||
public void SetValues(FP64Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -206,7 +206,7 @@ namespace BGC
|
|||
this.r3c3 = matrix.r3c3;
|
||||
}
|
||||
|
||||
public void SetValues(F32Matrix3x3 matrix)
|
||||
public void SetValues(FP32Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r1c2 = matrix.r1c2;
|
||||
|
|
@ -221,7 +221,7 @@ namespace BGC
|
|||
this.r3c3 = matrix.r3c3;
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F64Matrix3x3 matrix)
|
||||
public void SetTransposedOf(in FP64Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r2c2 = matrix.r2c2;
|
||||
|
|
@ -232,7 +232,7 @@ namespace BGC
|
|||
(this.r2c3, this.r3c2) = (matrix.r3c2, matrix.r2c3);
|
||||
}
|
||||
|
||||
public void SetTransposedOf(in F32Matrix3x3 matrix)
|
||||
public void SetTransposedOf(in FP32Matrix3x3 matrix)
|
||||
{
|
||||
this.r1c1 = matrix.r1c1;
|
||||
this.r2c2 = matrix.r2c2;
|
||||
|
|
@ -243,11 +243,11 @@ namespace BGC
|
|||
(this.r2c3, this.r3c2) = (matrix.r3c2, matrix.r2c3);
|
||||
}
|
||||
|
||||
public bool SetInvertedOf(in F64Matrix3x3 matrix)
|
||||
public bool SetInvertedOf(in FP64Matrix3x3 matrix)
|
||||
{
|
||||
double determinant = matrix.GetDeterminant();
|
||||
|
||||
if (-F64Utility.EPSYLON <= determinant && determinant <= F64Utility.EPSYLON) {
|
||||
if (-FP64Utility.EPSYLON <= determinant && determinant <= FP64Utility.EPSYLON) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ namespace BGC
|
|||
this.r3c3 = r3;
|
||||
}
|
||||
|
||||
public void AppendScaled(in F64Matrix3x3 matrix, double scale)
|
||||
public void AppendScaled(in FP64Matrix3x3 matrix, double scale)
|
||||
{
|
||||
this.r1c1 += matrix.r1c1 * scale;
|
||||
this.r1c2 += matrix.r1c2 * scale;
|
||||
|
|
@ -335,7 +335,7 @@ namespace BGC
|
|||
this.r3c3 += matrix.r3c3 * scale;
|
||||
}
|
||||
|
||||
public static void Add(in F64Matrix3x3 matrix1, in F64Matrix3x3 matrix2, out F64Matrix3x3 sum)
|
||||
public static void Add(in FP64Matrix3x3 matrix1, in FP64Matrix3x3 matrix2, out FP64Matrix3x3 sum)
|
||||
{
|
||||
sum.r1c1 = matrix1.r1c1 + matrix2.r1c1;
|
||||
sum.r1c2 = matrix1.r1c2 + matrix2.r1c2;
|
||||
|
|
@ -350,7 +350,7 @@ namespace BGC
|
|||
sum.r3c3 = matrix1.r3c3 + matrix2.r3c3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F64Matrix3x3 minuend, in F64Matrix3x3 subtrahend, out F64Matrix3x3 difference)
|
||||
public static void Subtract(in FP64Matrix3x3 minuend, in FP64Matrix3x3 subtrahend, out FP64Matrix3x3 difference)
|
||||
{
|
||||
difference.r1c1 = minuend.r1c1 - subtrahend.r1c1;
|
||||
difference.r1c2 = minuend.r1c2 - subtrahend.r1c2;
|
||||
|
|
@ -365,7 +365,7 @@ namespace BGC
|
|||
difference.r3c3 = minuend.r3c3 - subtrahend.r3c3;
|
||||
}
|
||||
|
||||
public static void Multiply(in F64Matrix3x3 multiplicand, double multiplier, out F64Matrix3x3 product)
|
||||
public static void Multiply(in FP64Matrix3x3 multiplicand, double multiplier, out FP64Matrix3x3 product)
|
||||
{
|
||||
product.r1c1 = multiplicand.r1c1 * multiplier;
|
||||
product.r1c2 = multiplicand.r1c2 * multiplier;
|
||||
|
|
@ -380,7 +380,7 @@ namespace BGC
|
|||
product.r3c3 = multiplicand.r3c3 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F64Matrix3x3 dividend, double divisor, out F64Matrix3x3 quotient)
|
||||
public static void Divide(in FP64Matrix3x3 dividend, double divisor, out FP64Matrix3x3 quotient)
|
||||
{
|
||||
quotient.r1c1 = dividend.r1c1 / divisor;
|
||||
quotient.r1c2 = dividend.r1c2 / divisor;
|
||||
|
|
@ -395,7 +395,7 @@ namespace BGC
|
|||
quotient.r3c3 = dividend.r3c3 / divisor;
|
||||
}
|
||||
|
||||
public static void GetRightProduct(in F64Matrix3x3 matrix, in F64Vector3 vector, out F64Vector3 result)
|
||||
public static void GetRightProduct(in FP64Matrix3x3 matrix, in FP64Vector3 vector, out FP64Vector3 result)
|
||||
{
|
||||
double x1 = matrix.r1c1 * vector.x1 + matrix.r1c2 * vector.x2 + matrix.r1c3 * vector.x3;
|
||||
double x2 = matrix.r2c1 * vector.x1 + matrix.r2c2 * vector.x2 + matrix.r2c3 * vector.x3;
|
||||
|
|
@ -406,7 +406,7 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public static void GetLeftProduct(in F64Vector3 vector, in F64Matrix3x3 matrix, out F64Vector3 result)
|
||||
public static void GetLeftProduct(in FP64Vector3 vector, in FP64Matrix3x3 matrix, out FP64Vector3 result)
|
||||
{
|
||||
double x1 = vector.x1 * matrix.r1c1 + vector.x2 * matrix.r2c1 + vector.x3 * matrix.r3c1;
|
||||
double x2 = vector.x1 * matrix.r1c2 + vector.x2 * matrix.r2c2 + vector.x3 * matrix.r3c2;
|
||||
|
|
@ -417,7 +417,7 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public static void LoadZero(out F64Matrix3x3 matrix)
|
||||
public static void LoadZero(out FP64Matrix3x3 matrix)
|
||||
{
|
||||
matrix.r1c1 = 0.0;
|
||||
matrix.r1c2 = 0.0;
|
||||
|
|
@ -432,7 +432,7 @@ namespace BGC
|
|||
matrix.r3c3 = 0.0;
|
||||
}
|
||||
|
||||
public static void LoadIdentity(out F64Matrix3x3 matrix)
|
||||
public static void LoadIdentity(out FP64Matrix3x3 matrix)
|
||||
{
|
||||
matrix.r1c1 = 1.0;
|
||||
matrix.r1c2 = 0.0;
|
||||
|
|
@ -447,7 +447,7 @@ namespace BGC
|
|||
matrix.r3c3 = 1.0;
|
||||
}
|
||||
|
||||
public static void LoadDiagonal(double d1, double d2, double d3, out F64Matrix3x3 matrix)
|
||||
public static void LoadDiagonal(double d1, double d2, double d3, out FP64Matrix3x3 matrix)
|
||||
{
|
||||
matrix.r1c1 = d1;
|
||||
matrix.r1c2 = 0.0;
|
||||
|
|
@ -22,9 +22,9 @@ using System;
|
|||
*/
|
||||
namespace BGC
|
||||
{
|
||||
public class F64MatrixProduct
|
||||
public class FP64MatrixProduct
|
||||
{
|
||||
public static void Get2x2At2x2(in F64Matrix2x2 left, in F64Matrix2x2 right, out F64Matrix2x2 product)
|
||||
public static void Get2x2At2x2(in FP64Matrix2x2 left, in FP64Matrix2x2 right, out FP64Matrix2x2 product)
|
||||
{
|
||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -39,7 +39,7 @@ namespace BGC
|
|||
product.r2c2 = r2c2;
|
||||
}
|
||||
|
||||
public static void Get2x2At3x2(in F64Matrix2x2 left, in F64Matrix3x2 right, out F64Matrix3x2 product)
|
||||
public static void Get2x2At3x2(in FP64Matrix2x2 left, in FP64Matrix3x2 right, out FP64Matrix3x2 product)
|
||||
{
|
||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -58,7 +58,7 @@ namespace BGC
|
|||
product.r2c3 = r2c3;
|
||||
}
|
||||
|
||||
public static void Get2x3At2x2(in F64Matrix2x3 left, in F64Matrix2x2 right, out F64Matrix2x3 product)
|
||||
public static void Get2x3At2x2(in FP64Matrix2x3 left, in FP64Matrix2x2 right, out FP64Matrix2x3 product)
|
||||
{
|
||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -79,7 +79,7 @@ namespace BGC
|
|||
product.r3c2 = r3c2;
|
||||
}
|
||||
|
||||
public static void Get2x3At3x2(in F64Matrix2x3 left, in F64Matrix3x2 right, out F64Matrix3x3 product)
|
||||
public static void Get2x3At3x2(in FP64Matrix2x3 left, in FP64Matrix3x2 right, out FP64Matrix3x3 product)
|
||||
{
|
||||
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1;
|
||||
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2;
|
||||
|
|
@ -94,7 +94,7 @@ namespace BGC
|
|||
product.r3c3 = left.r3c1 * right.r1c2 + left.r3c2 * right.r2c3;
|
||||
}
|
||||
|
||||
public static void Get3x2At3x3(in F64Matrix3x2 left, in F64Matrix3x3 right, out F64Matrix3x2 product)
|
||||
public static void Get3x2At3x3(in FP64Matrix3x2 left, in FP64Matrix3x3 right, out FP64Matrix3x2 product)
|
||||
{
|
||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -113,7 +113,7 @@ namespace BGC
|
|||
product.r2c3 = r2c3;
|
||||
}
|
||||
|
||||
public static void Get3x2At2x3(in F64Matrix3x2 left, in F64Matrix2x3 right, out F64Matrix2x2 product)
|
||||
public static void Get3x2At2x3(in FP64Matrix3x2 left, in FP64Matrix2x3 right, out FP64Matrix2x2 product)
|
||||
{
|
||||
product.r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
product.r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -122,7 +122,7 @@ namespace BGC
|
|||
product.r2c2 = left.r2c1 * right.r1c2 + left.r2c2 * right.r2c2 + left.r2c3 * right.r3c2;
|
||||
}
|
||||
|
||||
public static void Get3x3At2x3(in F64Matrix3x3 left, in F64Matrix2x3 right, out F64Matrix2x3 product)
|
||||
public static void Get3x3At2x3(in FP64Matrix3x3 left, in FP64Matrix2x3 right, out FP64Matrix2x3 product)
|
||||
{
|
||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -143,7 +143,7 @@ namespace BGC
|
|||
product.r3c2 = r3c2;
|
||||
}
|
||||
|
||||
public static void Get3x3At3x3(in F64Matrix3x3 left, in F64Matrix3x3 right, out F64Matrix3x3 product)
|
||||
public static void Get3x3At3x3(in FP64Matrix3x3 left, in FP64Matrix3x3 right, out FP64Matrix3x3 product)
|
||||
{
|
||||
double r1c1 = left.r1c1 * right.r1c1 + left.r1c2 * right.r2c1 + left.r1c3 * right.r3c1;
|
||||
double r1c2 = left.r1c1 * right.r1c2 + left.r1c2 * right.r2c2 + left.r1c3 * right.r3c2;
|
||||
|
|
@ -3,11 +3,11 @@ using System.Numerics;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Quaternion
|
||||
public struct FP64Quaternion
|
||||
{
|
||||
public double s0, x1, x2, x3;
|
||||
|
||||
public F64Quaternion(double s0, double x1, double x2, double x3)
|
||||
public FP64Quaternion(double s0, double x1, double x2, double x3)
|
||||
{
|
||||
this.s0 = s0;
|
||||
this.x1 = x1;
|
||||
|
|
@ -15,7 +15,7 @@ namespace BGC
|
|||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public F64Quaternion(in F32Quaternion quaternion)
|
||||
public FP64Quaternion(in FP32Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = quaternion.x1;
|
||||
|
|
@ -23,7 +23,7 @@ namespace BGC
|
|||
this.x3 = quaternion.x3;
|
||||
}
|
||||
|
||||
public F64Quaternion(in F64Quaternion quaternion)
|
||||
public FP64Quaternion(in FP64Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = quaternion.x1;
|
||||
|
|
@ -54,7 +54,7 @@ namespace BGC
|
|||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Quaternion quaternion)
|
||||
public void SetValues(in FP32Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = quaternion.x1;
|
||||
|
|
@ -62,7 +62,7 @@ namespace BGC
|
|||
this.x3 = quaternion.x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Quaternion quaternion)
|
||||
public void SetValues(in FP64Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = quaternion.x1;
|
||||
|
|
@ -70,7 +70,7 @@ namespace BGC
|
|||
this.x3 = quaternion.x3;
|
||||
}
|
||||
|
||||
public void SetConjugateOf(in F64Quaternion quaternion)
|
||||
public void SetConjugateOf(in FP64Quaternion quaternion)
|
||||
{
|
||||
this.s0 = quaternion.s0;
|
||||
this.x1 = -quaternion.x1;
|
||||
|
|
@ -78,7 +78,7 @@ namespace BGC
|
|||
this.x3 = -quaternion.x3;
|
||||
}
|
||||
|
||||
public readonly void MakeRotationMatrix(out F64Matrix3x3 matrix)
|
||||
public readonly void MakeRotationMatrix(out FP64Matrix3x3 matrix)
|
||||
{
|
||||
double s0s0 = this.s0 * this.s0;
|
||||
double x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -87,16 +87,16 @@ namespace BGC
|
|||
|
||||
double squareModule = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-F64Utility.EPSYLON <= squareModule && squareModule <= F64Utility.EPSYLON)
|
||||
if (-FP64Utility.EPSYLON <= squareModule && squareModule <= FP64Utility.EPSYLON)
|
||||
{
|
||||
F64Matrix3x3.LoadIdentity(out matrix);
|
||||
FP64Matrix3x3.LoadIdentity(out matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
double corrector1;
|
||||
double corrector2;
|
||||
|
||||
if (1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + F64Utility.TWO_EPSYLON) {
|
||||
if (1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + FP64Utility.TWO_EPSYLON) {
|
||||
corrector1 = 2.0 - squareModule;
|
||||
corrector2 = 2.0 * corrector1;
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ namespace BGC
|
|||
matrix.r1c3 = corrector2 * (x1x3 + s0x2);
|
||||
}
|
||||
|
||||
public readonly void MakeReverseMatrix(out F64Matrix3x3 matrix)
|
||||
public readonly void MakeReverseMatrix(out FP64Matrix3x3 matrix)
|
||||
{
|
||||
double s0s0 = this.s0 * this.s0;
|
||||
double x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -134,16 +134,16 @@ namespace BGC
|
|||
|
||||
double squareModule = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-F64Utility.EPSYLON <= squareModule && squareModule <= F64Utility.EPSYLON)
|
||||
if (-FP64Utility.EPSYLON <= squareModule && squareModule <= FP64Utility.EPSYLON)
|
||||
{
|
||||
F64Matrix3x3.LoadIdentity(out matrix);
|
||||
FP64Matrix3x3.LoadIdentity(out matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
double corrector1;
|
||||
double corrector2;
|
||||
|
||||
if (1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + F64Utility.TWO_EPSYLON) {
|
||||
if (1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + FP64Utility.TWO_EPSYLON) {
|
||||
corrector1 = 2.0 - squareModule;
|
||||
corrector2 = 2.0 * corrector1;
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ namespace BGC
|
|||
matrix.r1c3 = corrector2 * (x1x3 - s0x2);
|
||||
}
|
||||
|
||||
public static void Add(in F64Quaternion quaternion1, in F64Quaternion quaternion2, out F64Quaternion sum)
|
||||
public static void Add(in FP64Quaternion quaternion1, in FP64Quaternion quaternion2, out FP64Quaternion sum)
|
||||
{
|
||||
sum.s0 = quaternion1.s0 + quaternion2.s0;
|
||||
sum.x1 = quaternion1.x1 + quaternion2.x1;
|
||||
|
|
@ -180,7 +180,7 @@ namespace BGC
|
|||
sum.x3 = quaternion1.x3 + quaternion2.x3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F64Quaternion minuend, in F64Quaternion subtrahend, out F64Quaternion difference)
|
||||
public static void Subtract(in FP64Quaternion minuend, in FP64Quaternion subtrahend, out FP64Quaternion difference)
|
||||
{
|
||||
difference.s0 = minuend.s0 - subtrahend.s0;
|
||||
difference.x1 = minuend.x1 - subtrahend.x1;
|
||||
|
|
@ -188,7 +188,7 @@ namespace BGC
|
|||
difference.x3 = minuend.x3 - subtrahend.x3;
|
||||
}
|
||||
|
||||
public static void Multiply(in F64Quaternion left, in F64Quaternion right, out F64Quaternion product)
|
||||
public static void Multiply(in FP64Quaternion left, in FP64Quaternion right, out FP64Quaternion product)
|
||||
{
|
||||
double s0 = (left.s0 * right.s0 - left.x1 * right.x1) - (left.x2 * right.x2 + left.x3 * right.x3);
|
||||
double x1 = (left.x1 * right.s0 + left.s0 * right.x1) - (left.x3 * right.x2 - left.x2 * right.x3);
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F64Radians
|
||||
public class FP64Radians
|
||||
{
|
||||
public const double PI = 3.14159265358979324;
|
||||
public const double TWO_PI = 6.28318530717958648;
|
||||
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F64Turns
|
||||
public class FP64Turns
|
||||
{
|
||||
public static double TurnsToRadians(double turns)
|
||||
{
|
||||
return turns * F64Radians.TWO_PI;
|
||||
return turns * FP64Radians.TWO_PI;
|
||||
}
|
||||
|
||||
public static double TurnsToDegrees(double turns)
|
||||
|
|
@ -22,7 +22,7 @@ namespace BGC
|
|||
{
|
||||
if (toUnit == AngleUnit.RADIANS)
|
||||
{
|
||||
return turns * F64Radians.TWO_PI;
|
||||
return turns * FP64Radians.TWO_PI;
|
||||
}
|
||||
|
||||
if (toUnit == AngleUnit.DEGREES)
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public class F64Utility
|
||||
public class FP64Utility
|
||||
{
|
||||
public const double EPSYLON = 5E-14;
|
||||
public const double TWO_EPSYLON = 1E-13;
|
||||
|
|
@ -23,26 +23,26 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Vector2
|
||||
public struct FP64Vector2
|
||||
{
|
||||
public static readonly F64Vector2 ZERO = new F64Vector2(0.0, 0.0);
|
||||
public static readonly FP64Vector2 ZERO = new FP64Vector2(0.0, 0.0);
|
||||
|
||||
public double x1;
|
||||
public double x2;
|
||||
|
||||
public F64Vector2(double x1, double x2)
|
||||
public FP64Vector2(double x1, double x2)
|
||||
{
|
||||
this.x1 = x1;
|
||||
this.x2 = x2;
|
||||
}
|
||||
|
||||
public F64Vector2(in F64Vector2 vector)
|
||||
public FP64Vector2(in FP64Vector2 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
}
|
||||
|
||||
public F64Vector2(in F32Vector2 vector)
|
||||
public FP64Vector2(in FP32Vector2 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
|
|
@ -62,12 +62,12 @@ namespace BGC
|
|||
{
|
||||
double squareModule = this.GetSquareModule();
|
||||
|
||||
if (1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + F64Utility.TWO_EPSYLON)
|
||||
if (1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + FP64Utility.TWO_EPSYLON)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (squareModule <= F64Utility.SQUARE_EPSYLON)
|
||||
if (squareModule <= FP64Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
this.Reset();
|
||||
return 0;
|
||||
|
|
@ -89,13 +89,13 @@ namespace BGC
|
|||
|
||||
public readonly bool IsZero()
|
||||
{
|
||||
return this.GetSquareModule() <= F64Utility.SQUARE_EPSYLON;
|
||||
return this.GetSquareModule() <= FP64Utility.SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
public readonly bool IsUnit()
|
||||
{
|
||||
double squareModule = this.GetSquareModule();
|
||||
return 1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= F64Utility.EPSYLON;
|
||||
return 1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= FP64Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
@ -110,31 +110,31 @@ namespace BGC
|
|||
this.x2 = x2;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Vector2 vector)
|
||||
public void SetValues(in FP64Vector2 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Vector2 vector)
|
||||
public void SetValues(in FP32Vector2 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F64Vector2 vector)
|
||||
public void SetReverseOf(in FP64Vector2 vector)
|
||||
{
|
||||
this.x1 = -vector.x1;
|
||||
this.x2 = -vector.x2;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F32Vector2 vector)
|
||||
public void SetReverseOf(in FP32Vector2 vector)
|
||||
{
|
||||
this.x1 = -vector.x1;
|
||||
this.x2 = -vector.x2;
|
||||
}
|
||||
|
||||
public void AppendScaled(F64Vector2 summand, double scale)
|
||||
public void AppendScaled(FP64Vector2 summand, double scale)
|
||||
{
|
||||
this.x1 += summand.x1 * scale;
|
||||
this.x2 += summand.x2 * scale;
|
||||
|
|
@ -145,84 +145,84 @@ namespace BGC
|
|||
return String.Format("DPVector2({0}, {1})", this.x1, this.x2);
|
||||
}
|
||||
|
||||
public static void Add(in F64Vector2 vector1, in F64Vector2 vector2, out F64Vector2 sum)
|
||||
public static void Add(in FP64Vector2 vector1, in FP64Vector2 vector2, out FP64Vector2 sum)
|
||||
{
|
||||
sum.x1 = vector1.x1 + vector2.x1;
|
||||
sum.x2 = vector1.x2 + vector2.x2;
|
||||
}
|
||||
|
||||
public static void Subtract(in F64Vector2 minuend, in F64Vector2 subtrahend, out F64Vector2 difference)
|
||||
public static void Subtract(in FP64Vector2 minuend, in FP64Vector2 subtrahend, out FP64Vector2 difference)
|
||||
{
|
||||
difference.x1 = minuend.x1 - subtrahend.x1;
|
||||
difference.x2 = minuend.x2 - subtrahend.x2;
|
||||
}
|
||||
|
||||
public static void Muliply(in F64Vector2 multiplicand, double multiplier, out F64Vector2 product)
|
||||
public static void Muliply(in FP64Vector2 multiplicand, double multiplier, out FP64Vector2 product)
|
||||
{
|
||||
product.x1 = multiplicand.x1 * multiplier;
|
||||
product.x2 = multiplicand.x2 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F64Vector2 dividend, double divisor, out F64Vector2 quotient)
|
||||
public static void Divide(in FP64Vector2 dividend, double divisor, out FP64Vector2 quotient)
|
||||
{
|
||||
quotient.x1 = dividend.x1 / divisor;
|
||||
quotient.x2 = dividend.x2 / divisor;
|
||||
}
|
||||
|
||||
public static void GetMean2(in F64Vector2 vector1, in F64Vector2 vector2, out F64Vector2 result)
|
||||
public static void GetMean2(in FP64Vector2 vector1, in FP64Vector2 vector2, out FP64Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1) * 0.5;
|
||||
result.x2 = (vector1.x2 + vector2.x2) * 0.5;
|
||||
}
|
||||
|
||||
public static void GetMean3(in F64Vector2 vector1, in F64Vector2 vector2, in F64Vector2 vector3, out F64Vector2 result)
|
||||
public static void GetMean3(in FP64Vector2 vector1, in FP64Vector2 vector2, in FP64Vector2 vector3, out FP64Vector2 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * F64Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * F64Utility.ONE_THIRD;
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * FP64Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * FP64Utility.ONE_THIRD;
|
||||
}
|
||||
|
||||
public static double GetScalarProduct(in F64Vector2 vector1, in F64Vector2 vector2)
|
||||
public static double GetScalarProduct(in FP64Vector2 vector1, in FP64Vector2 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x1 + vector1.x2 * vector2.x2;
|
||||
}
|
||||
|
||||
public static double GetCrossProduct(in F64Vector2 vector1, in F64Vector2 vector2)
|
||||
public static double GetCrossProduct(in FP64Vector2 vector1, in FP64Vector2 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x2 - vector1.x2 * vector2.x1;
|
||||
}
|
||||
|
||||
public static double GetAngle(in F64Vector2 vector1, in F64Vector2 vector2, AngleUnit unit)
|
||||
public static double GetAngle(in FP64Vector2 vector1, in FP64Vector2 vector2, AngleUnit unit)
|
||||
{
|
||||
double squareModule1 = vector1.GetSquareModule();
|
||||
|
||||
if (squareModule1 <= F64Utility.SQUARE_EPSYLON)
|
||||
if (squareModule1 <= FP64Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double squareModule2 = vector2.GetSquareModule();
|
||||
|
||||
if (squareModule2 <= F64Utility.SQUARE_EPSYLON)
|
||||
if (squareModule2 <= FP64Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double cosine = F64Vector2.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2);
|
||||
double cosine = FP64Vector2.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2);
|
||||
|
||||
if (1.0 - F64Utility.EPSYLON <= cosine)
|
||||
if (1.0 - FP64Utility.EPSYLON <= cosine)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (cosine <= -(1.0 - F64Utility.EPSYLON))
|
||||
if (cosine <= -(1.0 - FP64Utility.EPSYLON))
|
||||
{
|
||||
return F64Angle.GetHalfCircle(unit);
|
||||
return FP64Angle.GetHalfCircle(unit);
|
||||
}
|
||||
|
||||
return F64Radians.ToUnits(Math.Acos(cosine), unit);
|
||||
return FP64Radians.ToUnits(Math.Acos(cosine), unit);
|
||||
}
|
||||
|
||||
public static double GetSquareDistance(in F64Vector2 vector1, in F64Vector2 vector2)
|
||||
public static double GetSquareDistance(in FP64Vector2 vector1, in FP64Vector2 vector2)
|
||||
{
|
||||
double dx1 = vector1.x1 - vector2.x1;
|
||||
double dx2 = vector1.x2 - vector2.x2;
|
||||
|
|
@ -230,29 +230,29 @@ namespace BGC
|
|||
return dx1 * dx1 + dx2 * dx2;
|
||||
}
|
||||
|
||||
public static double GetDistance(in F64Vector2 vector1, in F64Vector2 vector2)
|
||||
public static double GetDistance(in FP64Vector2 vector1, in FP64Vector2 vector2)
|
||||
{
|
||||
return Math.Sqrt(GetSquareDistance(vector1, vector2));
|
||||
}
|
||||
|
||||
public static bool AreEqual(in F64Vector2 vector1, in F64Vector2 vector2)
|
||||
public static bool AreEqual(in FP64Vector2 vector1, in FP64Vector2 vector2)
|
||||
{
|
||||
double squareModule1 = vector1.GetSquareModule();
|
||||
double squareModule2 = vector2.GetSquareModule();
|
||||
double squareModule3 = GetSquareDistance(vector1, vector2);
|
||||
|
||||
// 2.0 means dimension amount
|
||||
if (squareModule1 < F64Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < F64Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
if (squareModule1 < FP64Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < FP64Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
{
|
||||
return squareModule3 < (2.0 * F64Utility.SQUARE_EPSYLON);
|
||||
return squareModule3 < (2.0 * FP64Utility.SQUARE_EPSYLON);
|
||||
}
|
||||
|
||||
if (squareModule1 <= squareModule2)
|
||||
{
|
||||
return squareModule3 <= (2.0 * F64Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
return squareModule3 <= (2.0 * FP64Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
}
|
||||
|
||||
return squareModule3 <= (2.0 * F64Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
return squareModule3 <= (2.0 * FP64Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,29 +23,29 @@ using System;
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Vector3
|
||||
public struct FP64Vector3
|
||||
{
|
||||
public static readonly F64Vector3 ZERO = new F64Vector3(0.0, 0.0, 0.0);
|
||||
public static readonly FP64Vector3 ZERO = new FP64Vector3(0.0, 0.0, 0.0);
|
||||
|
||||
public double x1;
|
||||
public double x2;
|
||||
public double x3;
|
||||
|
||||
public F64Vector3(double x1, double x2, double x3)
|
||||
public FP64Vector3(double x1, double x2, double x3)
|
||||
{
|
||||
this.x1 = x1;
|
||||
this.x2 = x2;
|
||||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public F64Vector3(in F64Vector3 vector)
|
||||
public FP64Vector3(in FP64Vector3 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
this.x3 = vector.x3;
|
||||
}
|
||||
|
||||
public F64Vector3(in F32Vector3 vector)
|
||||
public FP64Vector3(in FP32Vector3 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
|
|
@ -66,12 +66,12 @@ namespace BGC
|
|||
{
|
||||
double squareModule = this.GetSquareModule();
|
||||
|
||||
if (1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + F64Utility.TWO_EPSYLON)
|
||||
if (1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + FP64Utility.TWO_EPSYLON)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (squareModule <= F64Utility.SQUARE_EPSYLON)
|
||||
if (squareModule <= FP64Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
this.Reset();
|
||||
return 0;
|
||||
|
|
@ -95,13 +95,13 @@ namespace BGC
|
|||
|
||||
public readonly bool IsZero()
|
||||
{
|
||||
return this.GetSquareModule() <= F64Utility.SQUARE_EPSYLON;
|
||||
return this.GetSquareModule() <= FP64Utility.SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
public readonly bool IsUnit()
|
||||
{
|
||||
double squareModule = this.GetSquareModule();
|
||||
return 1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= F64Utility.EPSYLON;
|
||||
return 1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= FP64Utility.EPSYLON;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
@ -118,35 +118,35 @@ namespace BGC
|
|||
this.x3 = x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F64Vector3 vector)
|
||||
public void SetValues(in FP64Vector3 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
this.x3 = vector.x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Vector3 vector)
|
||||
public void SetValues(in FP32Vector3 vector)
|
||||
{
|
||||
this.x1 = vector.x1;
|
||||
this.x2 = vector.x2;
|
||||
this.x3 = vector.x3;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F64Vector3 vector)
|
||||
public void SetReverseOf(in FP64Vector3 vector)
|
||||
{
|
||||
this.x1 = -vector.x1;
|
||||
this.x2 = -vector.x2;
|
||||
this.x3 = -vector.x3;
|
||||
}
|
||||
|
||||
public void SetReverseOf(in F32Vector3 vector)
|
||||
public void SetReverseOf(in FP32Vector3 vector)
|
||||
{
|
||||
this.x1 = -vector.x1;
|
||||
this.x2 = -vector.x2;
|
||||
this.x3 = -vector.x3;
|
||||
}
|
||||
|
||||
public void AppendScaled(F64Vector3 summand, double scale)
|
||||
public void AppendScaled(FP64Vector3 summand, double scale)
|
||||
{
|
||||
this.x1 += summand.x1 * scale;
|
||||
this.x2 += summand.x2 * scale;
|
||||
|
|
@ -158,54 +158,54 @@ namespace BGC
|
|||
return String.Format("DPVector3({0}, {1}, {2})", this.x1, this.x2, this.x3);
|
||||
}
|
||||
|
||||
public static void Add(in F64Vector3 vector1, in F64Vector3 vector2, out F64Vector3 sum)
|
||||
public static void Add(in FP64Vector3 vector1, in FP64Vector3 vector2, out FP64Vector3 sum)
|
||||
{
|
||||
sum.x1 = vector1.x1 + vector2.x1;
|
||||
sum.x2 = vector1.x2 + vector2.x2;
|
||||
sum.x3 = vector1.x3 + vector2.x3;
|
||||
}
|
||||
|
||||
public static void Subtract(in F64Vector3 minuend, in F64Vector3 subtrahend, out F64Vector3 difference)
|
||||
public static void Subtract(in FP64Vector3 minuend, in FP64Vector3 subtrahend, out FP64Vector3 difference)
|
||||
{
|
||||
difference.x1 = minuend.x1 - subtrahend.x1;
|
||||
difference.x2 = minuend.x2 - subtrahend.x2;
|
||||
difference.x3 = minuend.x3 - subtrahend.x3;
|
||||
}
|
||||
|
||||
public static void Muliply(in F64Vector3 multiplicand, double multiplier, out F64Vector3 product)
|
||||
public static void Muliply(in FP64Vector3 multiplicand, double multiplier, out FP64Vector3 product)
|
||||
{
|
||||
product.x1 = multiplicand.x1 * multiplier;
|
||||
product.x2 = multiplicand.x2 * multiplier;
|
||||
product.x3 = multiplicand.x3 * multiplier;
|
||||
}
|
||||
|
||||
public static void Divide(in F64Vector3 dividend, double divisor, out F64Vector3 quotient)
|
||||
public static void Divide(in FP64Vector3 dividend, double divisor, out FP64Vector3 quotient)
|
||||
{
|
||||
quotient.x1 = dividend.x1 / divisor;
|
||||
quotient.x2 = dividend.x2 / divisor;
|
||||
quotient.x3 = dividend.x3 / divisor;
|
||||
}
|
||||
|
||||
public static void GetMean2(in F64Vector3 vector1, in F64Vector3 vector2, out F64Vector3 result)
|
||||
public static void GetMean2(in FP64Vector3 vector1, in FP64Vector3 vector2, out FP64Vector3 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1) * 0.5;
|
||||
result.x2 = (vector1.x2 + vector2.x2) * 0.5;
|
||||
result.x3 = (vector1.x3 + vector2.x3) * 0.5;
|
||||
}
|
||||
|
||||
public static void GetMean3(in F64Vector3 vector1, in F64Vector3 vector2, in F64Vector3 vector3, out F64Vector3 result)
|
||||
public static void GetMean3(in FP64Vector3 vector1, in FP64Vector3 vector2, in FP64Vector3 vector3, out FP64Vector3 result)
|
||||
{
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * F64Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * F64Utility.ONE_THIRD;
|
||||
result.x3 = (vector1.x3 + vector2.x3 + vector3.x3) * F64Utility.ONE_THIRD;
|
||||
result.x1 = (vector1.x1 + vector2.x1 + vector3.x1) * FP64Utility.ONE_THIRD;
|
||||
result.x2 = (vector1.x2 + vector2.x2 + vector3.x2) * FP64Utility.ONE_THIRD;
|
||||
result.x3 = (vector1.x3 + vector2.x3 + vector3.x3) * FP64Utility.ONE_THIRD;
|
||||
}
|
||||
|
||||
public static double GetScalarProduct(in F64Vector3 vector1, in F64Vector3 vector2)
|
||||
public static double GetScalarProduct(in FP64Vector3 vector1, in FP64Vector3 vector2)
|
||||
{
|
||||
return vector1.x1 * vector2.x1 + vector1.x2 * vector2.x2 + vector1.x3 * vector2.x3;
|
||||
}
|
||||
|
||||
public static void GetCrossProduct(in F64Vector3 vector1, in F64Vector3 vector2, out F64Vector3 result)
|
||||
public static void GetCrossProduct(in FP64Vector3 vector1, in FP64Vector3 vector2, out FP64Vector3 result)
|
||||
{
|
||||
double x1 = vector1.x2 * vector2.x3 - vector1.x3 * vector2.x2;
|
||||
double x2 = vector1.x3 * vector2.x1 - vector1.x1 * vector2.x3;
|
||||
|
|
@ -216,14 +216,14 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public static double GetTripleProduct(in F64Vector3 vector1, in F64Vector3 vector2, in F64Vector3 vector3)
|
||||
public static double GetTripleProduct(in FP64Vector3 vector1, in FP64Vector3 vector2, in FP64Vector3 vector3)
|
||||
{
|
||||
return vector1.x1 * (vector2.x2 * vector3.x3 - vector2.x3 * vector3.x2)
|
||||
+ vector1.x2 * (vector2.x3 * vector3.x1 - vector2.x1 * vector3.x3)
|
||||
+ vector1.x3 * (vector2.x1 * vector3.x2 - vector2.x2 * vector3.x1);
|
||||
}
|
||||
|
||||
public static void GetDoubleCrossProduct(in F64Vector3 vector1, in F64Vector3 vector2, in F64Vector3 vector3, out F64Vector3 result)
|
||||
public static void GetDoubleCrossProduct(in FP64Vector3 vector1, in FP64Vector3 vector2, in FP64Vector3 vector3, out FP64Vector3 result)
|
||||
{
|
||||
// [a x [b x c]] = b * (a, c) - c * (a, b)
|
||||
double ac = GetScalarProduct(vector1, vector3);
|
||||
|
|
@ -234,38 +234,38 @@ namespace BGC
|
|||
result.x3 = ac * vector2.x3 - ab * vector3.x3;
|
||||
}
|
||||
|
||||
public static double GetAngle(in F64Vector3 vector1, in F64Vector3 vector2, AngleUnit unit)
|
||||
public static double GetAngle(in FP64Vector3 vector1, in FP64Vector3 vector2, AngleUnit unit)
|
||||
{
|
||||
double squareModule1 = vector1.GetSquareModule();
|
||||
|
||||
if (squareModule1 <= F64Utility.SQUARE_EPSYLON)
|
||||
if (squareModule1 <= FP64Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double squareModule2 = vector2.GetSquareModule();
|
||||
|
||||
if (squareModule2 <= F64Utility.SQUARE_EPSYLON)
|
||||
if (squareModule2 <= FP64Utility.SQUARE_EPSYLON)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double cosine = F64Vector3.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2);
|
||||
double cosine = FP64Vector3.GetScalarProduct(vector1, vector2) / Math.Sqrt(squareModule1 * squareModule2);
|
||||
|
||||
if (1.0 - F64Utility.EPSYLON <= cosine)
|
||||
if (1.0 - FP64Utility.EPSYLON <= cosine)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (cosine <= -(1.0 - F64Utility.EPSYLON))
|
||||
if (cosine <= -(1.0 - FP64Utility.EPSYLON))
|
||||
{
|
||||
return F64Angle.GetHalfCircle(unit);
|
||||
return FP64Angle.GetHalfCircle(unit);
|
||||
}
|
||||
|
||||
return F64Radians.ToUnits(Math.Acos(cosine), unit);
|
||||
return FP64Radians.ToUnits(Math.Acos(cosine), unit);
|
||||
}
|
||||
|
||||
public static double GetSquareDistance(in F64Vector3 vector1, in F64Vector3 vector2)
|
||||
public static double GetSquareDistance(in FP64Vector3 vector1, in FP64Vector3 vector2)
|
||||
{
|
||||
double dx1 = vector1.x1 - vector2.x1;
|
||||
double dx2 = vector1.x2 - vector2.x2;
|
||||
|
|
@ -274,29 +274,29 @@ namespace BGC
|
|||
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
|
||||
}
|
||||
|
||||
public static double GetDistance(in F64Vector3 vector1, in F64Vector3 vector2)
|
||||
public static double GetDistance(in FP64Vector3 vector1, in FP64Vector3 vector2)
|
||||
{
|
||||
return Math.Sqrt(GetSquareDistance(vector1, vector2));
|
||||
}
|
||||
|
||||
public static bool AreEqual(in F64Vector3 vector1, in F64Vector3 vector2)
|
||||
public static bool AreEqual(in FP64Vector3 vector1, in FP64Vector3 vector2)
|
||||
{
|
||||
double squareModule1 = vector1.GetSquareModule();
|
||||
double squareModule2 = vector2.GetSquareModule();
|
||||
double squareModule3 = GetSquareDistance(vector1, vector2);
|
||||
|
||||
// 3.0 means dimension amount
|
||||
if (squareModule1 < F64Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < F64Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
if (squareModule1 < FP64Utility.EPSYLON_EFFECTIVENESS_LIMIT || squareModule2 < FP64Utility.EPSYLON_EFFECTIVENESS_LIMIT)
|
||||
{
|
||||
return squareModule3 < (3.0 * F64Utility.SQUARE_EPSYLON);
|
||||
return squareModule3 < (3.0 * FP64Utility.SQUARE_EPSYLON);
|
||||
}
|
||||
|
||||
if (squareModule1 <= squareModule2)
|
||||
{
|
||||
return squareModule3 <= (3.0 * F64Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
return squareModule3 <= (3.0 * FP64Utility.SQUARE_EPSYLON) * squareModule2;
|
||||
}
|
||||
|
||||
return squareModule3 <= (3.0 * F64Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
return squareModule3 <= (3.0 * FP64Utility.SQUARE_EPSYLON) * squareModule1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,14 +22,14 @@
|
|||
|
||||
namespace BGC
|
||||
{
|
||||
public struct F64Versor
|
||||
public struct FP64Versor
|
||||
{
|
||||
private double s0;
|
||||
private double x1;
|
||||
private double x2;
|
||||
private double x3;
|
||||
|
||||
public F64Versor()
|
||||
public FP64Versor()
|
||||
{
|
||||
this.s0 = 1.0;
|
||||
this.x1 = 0.0;
|
||||
|
|
@ -37,12 +37,12 @@ namespace BGC
|
|||
this.x3 = 0.0;
|
||||
}
|
||||
|
||||
public F64Versor(double s0, double x1, double x2, double x3)
|
||||
public FP64Versor(double s0, double x1, double x2, double x3)
|
||||
{
|
||||
LoadValues(s0, x1, x2, x3, out this);
|
||||
}
|
||||
|
||||
public F64Versor(in F64Versor versor)
|
||||
public FP64Versor(in FP64Versor versor)
|
||||
{
|
||||
this.s0 = versor.s0;
|
||||
this.x1 = versor.x1;
|
||||
|
|
@ -50,7 +50,7 @@ namespace BGC
|
|||
this.x3 = versor.x3;
|
||||
}
|
||||
|
||||
public F64Versor(in F32Versor versor)
|
||||
public FP64Versor(in FP32Versor versor)
|
||||
{
|
||||
LoadValues(
|
||||
versor.GetScalar(),
|
||||
|
|
@ -82,7 +82,7 @@ namespace BGC
|
|||
|
||||
public readonly bool IsIdle()
|
||||
{
|
||||
return this.s0 <= -(1.0 - F64Utility.EPSYLON) || (1.0 - F64Utility.EPSYLON) <= this.s0;
|
||||
return this.s0 <= -(1.0 - FP64Utility.EPSYLON) || (1.0 - FP64Utility.EPSYLON) <= this.s0;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
|
|
@ -102,19 +102,19 @@ namespace BGC
|
|||
|
||||
public readonly double GetAngle(AngleUnit unit)
|
||||
{
|
||||
if (this.s0 <= -(1.0 - F64Utility.TWO_EPSYLON) || 1.0 - F64Utility.TWO_EPSYLON <= this.s0) {
|
||||
if (this.s0 <= -(1.0 - FP64Utility.TWO_EPSYLON) || 1.0 - FP64Utility.TWO_EPSYLON <= this.s0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (-F64Utility.EPSYLON <= this.s0 && this.s0 <= F64Utility.EPSYLON)
|
||||
if (-FP64Utility.EPSYLON <= this.s0 && this.s0 <= FP64Utility.EPSYLON)
|
||||
{
|
||||
return F64Angle.GetHalfCircle(unit);
|
||||
return FP64Angle.GetHalfCircle(unit);
|
||||
}
|
||||
|
||||
return F64Radians.ToUnits(2.0 * Math.Acos(s0), unit);
|
||||
return FP64Radians.ToUnits(2.0 * Math.Acos(s0), unit);
|
||||
}
|
||||
|
||||
public readonly void MakeRotationMatrix(out F64Matrix3x3 matrix)
|
||||
public readonly void MakeRotationMatrix(out FP64Matrix3x3 matrix)
|
||||
{
|
||||
double s0s0 = this.s0 * this.s0;
|
||||
double x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -143,7 +143,7 @@ namespace BGC
|
|||
matrix.r1c3 = x1x3 + s0x2;
|
||||
}
|
||||
|
||||
public readonly void MakeReverseMatrix(out F64Matrix3x3 matrix)
|
||||
public readonly void MakeReverseMatrix(out FP64Matrix3x3 matrix)
|
||||
{
|
||||
double s0s0 = this.s0 * this.s0;
|
||||
double x1x1 = this.x1 * this.x1;
|
||||
|
|
@ -180,9 +180,9 @@ namespace BGC
|
|||
|
||||
double squareModule = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + F64Utility.TWO_EPSYLON)
|
||||
if (1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + FP64Utility.TWO_EPSYLON)
|
||||
{
|
||||
if (-1.0 + F64Utility.EPSYLON < s0)
|
||||
if (-1.0 + FP64Utility.EPSYLON < s0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ namespace BGC
|
|||
this.Normalize(squareModule);
|
||||
}
|
||||
|
||||
public void SetValues(in F64Versor versor)
|
||||
public void SetValues(in FP64Versor versor)
|
||||
{
|
||||
this.s0 = versor.s0;
|
||||
this.x1 = versor.x1;
|
||||
|
|
@ -202,7 +202,7 @@ namespace BGC
|
|||
this.x3 = versor.x3;
|
||||
}
|
||||
|
||||
public void SetValues(in F32Versor versor)
|
||||
public void SetValues(in FP32Versor versor)
|
||||
{
|
||||
LoadValues(
|
||||
versor.GetScalar(),
|
||||
|
|
@ -212,7 +212,7 @@ namespace BGC
|
|||
out this);
|
||||
}
|
||||
|
||||
public void SetInverted(in F64Versor versor)
|
||||
public void SetInverted(in FP64Versor versor)
|
||||
{
|
||||
this.s0 = versor.s0;
|
||||
this.x1 = -versor.x1;
|
||||
|
|
@ -220,7 +220,7 @@ namespace BGC
|
|||
this.x3 = -versor.x3;
|
||||
}
|
||||
|
||||
public void SetInverted(in F32Versor versor)
|
||||
public void SetInverted(in FP32Versor versor)
|
||||
{
|
||||
LoadValues(
|
||||
versor.GetScalar(),
|
||||
|
|
@ -230,7 +230,7 @@ namespace BGC
|
|||
out this);
|
||||
}
|
||||
|
||||
public readonly void Turn(in F64Vector3 vector, out F64Vector3 result)
|
||||
public readonly void Turn(in FP64Vector3 vector, out FP64Vector3 result)
|
||||
{
|
||||
double tx1 = 2.0 * (this.x2 * vector.x3 - this.x3 * vector.x2);
|
||||
double tx2 = 2.0 * (this.x3 * vector.x1 - this.x1 * vector.x3);
|
||||
|
|
@ -245,7 +245,7 @@ namespace BGC
|
|||
result.x3 = x3;
|
||||
}
|
||||
|
||||
public readonly void TurnBack(in F64Vector3 vector, out F64Vector3 result)
|
||||
public readonly void TurnBack(in FP64Vector3 vector, out FP64Vector3 result)
|
||||
{
|
||||
double tx1 = 2.0 * (this.x2 * vector.x3 - this.x3 * vector.x2);
|
||||
double tx2 = 2.0 * (this.x3 * vector.x1 - this.x1 * vector.x3);
|
||||
|
|
@ -262,7 +262,7 @@ namespace BGC
|
|||
|
||||
private void Normalize(double squareModule)
|
||||
{
|
||||
if (squareModule <= F64Utility.SQUARE_EPSYLON || (this.x1 * this.x1 + this.x2 * this.x2 + this.x3 * this.x3) <= F64Utility.SQUARE_EPSYLON * squareModule)
|
||||
if (squareModule <= FP64Utility.SQUARE_EPSYLON || (this.x1 * this.x1 + this.x2 * this.x2 + this.x3 * this.x3) <= FP64Utility.SQUARE_EPSYLON * squareModule)
|
||||
{
|
||||
this.Reset();
|
||||
return;
|
||||
|
|
@ -276,7 +276,7 @@ namespace BGC
|
|||
this.x3 /= module;
|
||||
}
|
||||
|
||||
public static void Combine(in F64Versor second, in F64Versor first, out F64Versor result)
|
||||
public static void Combine(in FP64Versor second, in FP64Versor first, out FP64Versor result)
|
||||
{
|
||||
double s0 = (second.s0 * first.s0 - second.x1 * first.x1) - (second.x2 * first.x2 + second.x3 * first.x3);
|
||||
double x1 = (second.x1 * first.s0 + second.s0 * first.x1) - (second.x3 * first.x2 - second.x2 * first.x3);
|
||||
|
|
@ -290,13 +290,13 @@ namespace BGC
|
|||
result.x2 = x2;
|
||||
result.x3 = x3;
|
||||
|
||||
if (squareModule < 1.0 - F64Utility.TWO_EPSYLON || 1.0 + F64Utility.TWO_EPSYLON < squareModule)
|
||||
if (squareModule < 1.0 - FP64Utility.TWO_EPSYLON || 1.0 + FP64Utility.TWO_EPSYLON < squareModule)
|
||||
{
|
||||
result.Normalize(squareModule);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadIdle(out F64Versor versor)
|
||||
public static void LoadIdle(out FP64Versor versor)
|
||||
{
|
||||
versor.s0 = 1.0;
|
||||
versor.x1 = 0.0;
|
||||
|
|
@ -304,7 +304,7 @@ namespace BGC
|
|||
versor.x3 = 0.0;
|
||||
}
|
||||
|
||||
public static void LoadValues(double s0, double x1, double x2, double x3, out F64Versor versor)
|
||||
public static void LoadValues(double s0, double x1, double x2, double x3, out FP64Versor versor)
|
||||
{
|
||||
versor.s0 = s0;
|
||||
versor.x1 = x1;
|
||||
|
|
@ -313,9 +313,9 @@ namespace BGC
|
|||
|
||||
double squareModule = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0 - F64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + F64Utility.TWO_EPSYLON)
|
||||
if (1.0 - FP64Utility.TWO_EPSYLON <= squareModule && squareModule <= 1.0 + FP64Utility.TWO_EPSYLON)
|
||||
{
|
||||
if (-1.0 + F64Utility.EPSYLON < s0)
|
||||
if (-1.0 + FP64Utility.EPSYLON < s0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -6,14 +6,14 @@ using BGC;
|
|||
|
||||
public static class Program
|
||||
{
|
||||
private static F32Versor[] AllocateVersors(int amount)
|
||||
private static FP32Versor[] AllocateVersors(int amount)
|
||||
{
|
||||
return new F32Versor[amount];
|
||||
return new FP32Versor[amount];
|
||||
}
|
||||
|
||||
private static F32Versor[] MakeZeroVersors(int amount)
|
||||
private static FP32Versor[] MakeZeroVersors(int amount)
|
||||
{
|
||||
F32Versor[] versors = AllocateVersors(amount);
|
||||
FP32Versor[] versors = AllocateVersors(amount);
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
|
|
@ -23,15 +23,15 @@ public static class Program
|
|||
return versors;
|
||||
}
|
||||
|
||||
private static F32Versor[] MakeRandomVersors(int amount)
|
||||
private static FP32Versor[] MakeRandomVersors(int amount)
|
||||
{
|
||||
Random randomizer = new Random(Environment.TickCount);
|
||||
|
||||
F32Versor[] versors = AllocateVersors(amount);
|
||||
FP32Versor[] versors = AllocateVersors(amount);
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
versors[i] = new F32Versor(
|
||||
versors[i] = new FP32Versor(
|
||||
randomizer.NextSingle(),
|
||||
randomizer.NextSingle(),
|
||||
randomizer.NextSingle(),
|
||||
|
|
@ -42,7 +42,7 @@ public static class Program
|
|||
return versors;
|
||||
}
|
||||
|
||||
private static void PrintVersor(in F32Versor versor)
|
||||
private static void PrintVersor(in FP32Versor versor)
|
||||
{
|
||||
Console.WriteLine("({0}, {1}, {2}, {3})", versor.GetScalar(), versor.GetX1(), versor.GetX2(), versor.GetX3());
|
||||
}
|
||||
|
|
@ -51,9 +51,9 @@ public static class Program
|
|||
{
|
||||
int amount = 1000000;
|
||||
|
||||
F32Versor[] versors1 = MakeRandomVersors(amount);
|
||||
F32Versor[] versors2 = MakeRandomVersors(amount);
|
||||
F32Versor[] results = MakeZeroVersors(amount);
|
||||
FP32Versor[] versors1 = MakeRandomVersors(amount);
|
||||
FP32Versor[] versors2 = MakeRandomVersors(amount);
|
||||
FP32Versor[] results = MakeZeroVersors(amount);
|
||||
|
||||
long start, end;
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ public static class Program
|
|||
{
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
F32Versor.Combine(versors1[i], versors2[i], out results[i]);
|
||||
FP32Versor.Combine(versors1[i], versors2[i], out results[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ using BGC;
|
|||
namespace BGCTest
|
||||
{
|
||||
[TestClass]
|
||||
public class F32Vector2Test
|
||||
public class FP32Vector2Test
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestInitialization()
|
||||
{
|
||||
F32Vector2 vector = new F32Vector2(1.0f, 2.0f);
|
||||
FP32Vector2 vector = new FP32Vector2(1.0f, 2.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue