Skip to content

Commit 8f94777

Browse files
committed
refactor(api)!: remove float-based numeric/vector overloads for determinism
1 parent 69ff680 commit 8f94777

4 files changed

Lines changed: 0 additions & 58 deletions

File tree

src/FixedMathSharp/Numerics/Vector2d.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ public partial struct Vector2d : IEquatable<Vector2d>, IComparable<Vector2d>, IE
9191

9292
public Vector2d(int xInt, int yInt) : this((Fixed64)xInt, (Fixed64)yInt) { }
9393

94-
public Vector2d(float xFloat, float yFloat) : this((Fixed64)xFloat, (Fixed64)yFloat) { }
95-
9694
public Vector2d(double xDoub, double yDoub) : this((Fixed64)xDoub, (Fixed64)yDoub) { }
9795

9896
[JsonConstructor]
@@ -895,18 +893,6 @@ public static Vector2d ToRadians(Vector2d degrees)
895893
return v1 + v2;
896894
}
897895

898-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
899-
public static Vector2d operator +(Vector2d v1, (float x, float y) v2)
900-
{
901-
return new Vector2d(v1.x + v2.x, v1.y + v2.y);
902-
}
903-
904-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
905-
public static Vector2d operator +((float x, float y) v1, Vector2d v2)
906-
{
907-
return v2 + v1;
908-
}
909-
910896
[MethodImpl(MethodImplOptions.AggressiveInlining)]
911897
public static Vector2d operator -(Vector2d v1, Vector2d v2)
912898
{
@@ -937,18 +923,6 @@ public static Vector2d ToRadians(Vector2d degrees)
937923
return new Vector2d(v1.x - v2.x, v1.y - v2.y);
938924
}
939925

940-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
941-
public static Vector2d operator -(Vector2d v1, (float x, float y) v2)
942-
{
943-
return new Vector2d(v1.x - v2.x, v1.y - v2.y);
944-
}
945-
946-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
947-
public static Vector2d operator -((float x, float y) v1, Vector2d v2)
948-
{
949-
return new Vector2d(v1.x - v2.x, v1.y - v2.y);
950-
}
951-
952926
[MethodImpl(MethodImplOptions.AggressiveInlining)]
953927
public static Vector2d operator -(Vector2d v1)
954928
{

src/FixedMathSharp/Numerics/Vector3d.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,18 +1074,6 @@ public static Vector3d InverseRotate(Vector3d source, Vector3d position, FixedQu
10741074
return v1 + v2;
10751075
}
10761076

1077-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1078-
public static Vector3d operator +(Vector3d v1, (float x, float y, float z) v2)
1079-
{
1080-
return new Vector3d(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
1081-
}
1082-
1083-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1084-
public static Vector3d operator +((float x, float y, float z) v1, Vector3d v2)
1085-
{
1086-
return v2 + v1;
1087-
}
1088-
10891077
[MethodImpl(MethodImplOptions.AggressiveInlining)]
10901078
public static Vector3d operator -(Vector3d v1, Vector3d v2)
10911079
{
@@ -1116,18 +1104,6 @@ public static Vector3d InverseRotate(Vector3d source, Vector3d position, FixedQu
11161104
return new Vector3d(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
11171105
}
11181106

1119-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1120-
public static Vector3d operator -(Vector3d v1, (float x, float y, float z) v2)
1121-
{
1122-
return new Vector3d(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
1123-
}
1124-
1125-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1126-
public static Vector3d operator -((float x, float y, float z) v1, Vector3d v2)
1127-
{
1128-
return new Vector3d(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
1129-
}
1130-
11311107
[MethodImpl(MethodImplOptions.AggressiveInlining)]
11321108
public static Vector3d operator -(Vector3d v1)
11331109
{

tests/FixedMathSharp.Tests/Vector2d.Tests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,8 @@ public void OperatorOverloads_WithTuplesFloatsAndUnaryMinus_WorkCorrectly()
572572
Assert.Equal(new Vector2d(2, 3), Fixed64.One + vector);
573573
Assert.Equal(new Vector2d(4, 6), vector + (3, 4));
574574
Assert.Equal(new Vector2d(4, 6), (3, 4) + vector);
575-
Assert.Equal(new Vector2d(new Fixed64(1.5), new Fixed64(3.5)), vector + (0.5f, 1.5f));
576-
Assert.Equal(new Vector2d(new Fixed64(1.5), new Fixed64(3.5)), (0.5f, 1.5f) + vector);
577575
Assert.Equal(new Vector2d(-2, -2), vector - (3, 4));
578576
Assert.Equal(new Vector2d(2, 2), (3, 4) - vector);
579-
Assert.Equal(new Vector2d(new Fixed64(0.5), new Fixed64(0.5)), vector - (0.5f, 1.5f));
580-
Assert.Equal(new Vector2d(new Fixed64(-0.5), new Fixed64(-0.5)), (0.5f, 1.5f) - vector);
581577
Assert.Equal(new Vector2d(-1, -2), -vector);
582578
Assert.Equal(new Vector2d(2, 4), vector * new Fixed64(2));
583579
Assert.Equal(new Vector2d(2, 6), vector * new Vector2d(2, 3));

tests/FixedMathSharp.Tests/Vector3d.Tests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,8 @@ public void OperatorOverloads_WithScalarsTuplesFloatsAndComponentArithmetic_Work
751751
Assert.Equal(new Vector3d(2, 3, 4), Fixed64.One + vector);
752752
Assert.Equal(new Vector3d(4, 6, 8), vector + (3, 4, 5));
753753
Assert.Equal(new Vector3d(4, 6, 8), (3, 4, 5) + vector);
754-
Assert.Equal(new Vector3d(new Fixed64(1.5), new Fixed64(3.5), new Fixed64(5.5)), vector + (0.5f, 1.5f, 2.5f));
755-
Assert.Equal(new Vector3d(new Fixed64(1.5), new Fixed64(3.5), new Fixed64(5.5)), (0.5f, 1.5f, 2.5f) + vector);
756754
Assert.Equal(new Vector3d(-2, -2, -2), vector - (3, 4, 5));
757755
Assert.Equal(new Vector3d(2, 2, 2), (3, 4, 5) - vector);
758-
Assert.Equal(new Vector3d(new Fixed64(0.5), new Fixed64(0.5), new Fixed64(0.5)), vector - (0.5f, 1.5f, 2.5f));
759-
Assert.Equal(new Vector3d(new Fixed64(-0.5), new Fixed64(-0.5), new Fixed64(-0.5)), (0.5f, 1.5f, 2.5f) - vector);
760756
Assert.Equal(new Vector3d(-1, -2, -3), -vector);
761757
Assert.Equal(new Vector3d(2, 4, 6), vector * new Fixed64(2));
762758
Assert.Equal(new Vector3d(2, 4, 6), new Fixed64(2) * vector);

0 commit comments

Comments
 (0)