Skip to content

Commit ac3c27c

Browse files
Fixed class diagram & small changes
1 parent ed0b91c commit ac3c27c

File tree

16 files changed

+62
-75
lines changed

16 files changed

+62
-75
lines changed

SharpMath.Tests/PolygonTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void CanCalculateArea()
3333
{
3434
var square =
3535
new Polygon(new Point2D(0, 0), new Point2D(2, 0), new Point2D(2, 2), new Point2D(0, 2));
36-
Assert.IsTrue(FloatingNumber.CheckApproximatelyEqual(4, square.Area));
36+
Assert.IsTrue(FloatingNumber.AreApproximatelyEqual(4, square.Area));
3737

3838
var triangle =
3939
new Polygon(new Point2D(0, 0), new Point2D(2, 0), new Point2D(1, 2));

SharpMath.Tests/VectorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void CanRotateTwoDimensionalVector()
112112
{
113113
var firstVector = new Vector2(0, 1);
114114
var rotatedVector = Matrix3x3.Rotation(MathHelper.DegreesToRadians(180))*firstVector;
115-
Assert.IsTrue(FloatingNumber.CheckApproximatelyEqual(firstVector.X, 0));
115+
Assert.IsTrue(FloatingNumber.AreApproximatelyEqual(firstVector.X, 0));
116116
Assert.AreEqual(-1, rotatedVector.Y);
117117
}
118118

@@ -156,7 +156,7 @@ public void CanCalculateArea()
156156
var thirdVector = new Vector2(2, 4);
157157
var fourthVector = new Vector2(3, 1);
158158
double secondArea = Vector2.Area(thirdVector, fourthVector);
159-
Assert.IsTrue(FloatingNumber.CheckApproximatelyEqual(10, secondArea));
159+
Assert.IsTrue(FloatingNumber.AreApproximatelyEqual(10, secondArea));
160160
}
161161

162162
[TestMethod]

SharpMath/FloatingNumber.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public static class FloatingNumber
2222
/// <param name="firstNumber">The first <see cref="float" />.</param>
2323
/// <param name="secondNumber">The second <see cref="float" />.</param>
2424
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
25-
public static bool CheckApproximatelyEqual(float firstNumber, float secondNumber)
26-
=> CheckApproximatelyEqual(firstNumber, secondNumber, Epsilon);
25+
public static bool AreApproximatelyEqual(float firstNumber, float secondNumber)
26+
=> AreApproximatelyEqual(firstNumber, secondNumber, Epsilon);
2727

2828
/// <summary>
2929
/// Determines whether two floating numbers are approximately equal to each other using the specified epsilon value.
@@ -32,8 +32,8 @@ public static bool CheckApproximatelyEqual(float firstNumber, float secondNumber
3232
/// <param name="secondNumber">The second <see cref="float" />.</param>
3333
/// <param name="epsilon">The epsilon value that represents the tolerance.</param>
3434
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
35-
public static bool CheckApproximatelyEqual(float firstNumber, float secondNumber, double epsilon)
36-
=> Math.Abs(firstNumber - secondNumber) <= Epsilon;
35+
public static bool AreApproximatelyEqual(float firstNumber, float secondNumber, double epsilon)
36+
=> Math.Abs(firstNumber - secondNumber) <= epsilon;
3737

3838
/// <summary>
3939
/// Determines whether two floating numbers are approximately equal to each other using the <see cref="Epsilon" />
@@ -42,8 +42,8 @@ public static bool CheckApproximatelyEqual(float firstNumber, float secondNumber
4242
/// <param name="firstNumber">The first <see cref="float" />.</param>
4343
/// <param name="secondNumber">The second <see cref="float" />.</param>
4444
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
45-
public static bool CheckApproximatelyEqual(double firstNumber, double secondNumber)
46-
=> CheckApproximatelyEqual(firstNumber, secondNumber, Epsilon);
45+
public static bool AreApproximatelyEqual(double firstNumber, double secondNumber)
46+
=> AreApproximatelyEqual(firstNumber, secondNumber, Epsilon);
4747

4848
/// <summary>
4949
/// Determines whether two floating numbers are approximately equal to each other using the specified epsilon value.
@@ -52,7 +52,7 @@ public static bool CheckApproximatelyEqual(double firstNumber, double secondNumb
5252
/// <param name="secondNumber">The second <see cref="float" />.</param>
5353
/// <param name="epsilon">The epsilon value that represents the tolerance.</param>
5454
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
55-
public static bool CheckApproximatelyEqual(double firstNumber, double secondNumber, double epsilon)
56-
=> Math.Abs(firstNumber - secondNumber) <= Epsilon;
55+
public static bool AreApproximatelyEqual(double firstNumber, double secondNumber, double epsilon)
56+
=> Math.Abs(firstNumber - secondNumber) <= epsilon;
5757
}
5858
}

SharpMath/FloatingNumberExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class FloatingNumberExtensions
1616
/// <param name="other">The other <see cref="float" />.</param>
1717
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
1818
public static bool IsApproximatelyEqualTo(this float number, float other)
19-
=> FloatingNumber.CheckApproximatelyEqual(number, other);
19+
=> FloatingNumber.AreApproximatelyEqual(number, other);
2020

2121
/// <summary>
2222
/// Determines whether two floating numbers are approximately equal to each other using the specified epsilon value.
@@ -26,7 +26,7 @@ public static bool IsApproximatelyEqualTo(this float number, float other)
2626
/// <param name="epsilon">The epsilon value that represents the tolerance.</param>
2727
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
2828
public static bool IsApproximatelyEqualTo(this float number, float other, double epsilon)
29-
=> FloatingNumber.CheckApproximatelyEqual(number, other, epsilon);
29+
=> FloatingNumber.AreApproximatelyEqual(number, other, epsilon);
3030

3131
/// <summary>
3232
/// Determines whether two floating numbers are approximately equal to each other using the <see cref="Epsilon" />
@@ -36,7 +36,7 @@ public static bool IsApproximatelyEqualTo(this float number, float other, double
3636
/// <param name="other">The other <see cref="float" />.</param>
3737
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
3838
public static bool IsApproximatelyEqualTo(this double number, double other)
39-
=> FloatingNumber.CheckApproximatelyEqual(number, other);
39+
=> FloatingNumber.AreApproximatelyEqual(number, other);
4040

4141
/// <summary>
4242
/// Determines whether two floating numbers are approximately equal to each other using the specified epsilon value.
@@ -46,6 +46,6 @@ public static bool IsApproximatelyEqualTo(this double number, double other)
4646
/// <param name="epsilon">The epsilon value that represents the tolerance.</param>
4747
/// <returns>Returns <c>true</c>, if they are approximately equal, otherwise <c>false</c>.</returns>
4848
public static bool IsApproximatelyEqualTo(this double number, double other, double epsilon)
49-
=> FloatingNumber.CheckApproximatelyEqual(number, other, epsilon);
49+
=> FloatingNumber.AreApproximatelyEqual(number, other, epsilon);
5050
}
5151
}

SharpMath/Geometry/Line2D.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public bool IsPointOnLine(Point2D point)
8787
/// </returns>
8888
public bool IsParallelTo(Line2D line)
8989
{
90-
return FloatingNumber.CheckApproximatelyEqual(Slope, line.Slope);
90+
return FloatingNumber.AreApproximatelyEqual(Slope, line.Slope);
9191
}
9292

9393
/// <summary>

SharpMath/Geometry/Line3D.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public bool IsPointOnLine(Point3D point)
7575
for (uint i = 0; i < 3; ++i)
7676
{
7777
double value = (point[i] - Point[i])/Direction[i];
78-
if (i != 0 && !FloatingNumber.CheckApproximatelyEqual(value, lambda))
78+
if (i != 0 && !FloatingNumber.AreApproximatelyEqual(value, lambda))
7979
return false;
8080
lambda = value;
8181
}

SharpMath/Geometry/Matrix.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public bool IsDiagonal
7777
for (uint y = 0; y < RowCount; ++y)
7878
for (uint x = 0; x < ColumnCount; ++x)
7979
{
80-
if ((y == x && FloatingNumber.CheckApproximatelyEqual(this[y, x], 0)) ||
81-
(y != x && !FloatingNumber.CheckApproximatelyEqual(this[y, x], 0)))
80+
if ((y == x && FloatingNumber.AreApproximatelyEqual(this[y, x], 0)) ||
81+
(y != x && !FloatingNumber.AreApproximatelyEqual(this[y, x], 0)))
8282
return false;
8383
}
8484
return true;
@@ -95,8 +95,8 @@ public bool IsTriangle
9595
for (uint y = 0; y < RowCount; ++y)
9696
for (uint x = 0; x < ColumnCount; ++x)
9797
{
98-
if ((y == x && FloatingNumber.CheckApproximatelyEqual(this[y, x], 0)) ||
99-
(y != x && !FloatingNumber.CheckApproximatelyEqual(this[y, x], 0)))
98+
if ((y == x && FloatingNumber.AreApproximatelyEqual(this[y, x], 0)) ||
99+
(y != x && !FloatingNumber.AreApproximatelyEqual(this[y, x], 0)))
100100
return false;
101101
}
102102
return true;
@@ -328,7 +328,7 @@ public static bool AreEqual(Matrix firstMatrix, Matrix secondMatrix)
328328
{
329329
for (uint x = 0; x < firstMatrix.ColumnCount; ++x)
330330
{
331-
if (!FloatingNumber.CheckApproximatelyEqual(firstMatrix[y, x], secondMatrix[y, x]))
331+
if (!FloatingNumber.AreApproximatelyEqual(firstMatrix[y, x], secondMatrix[y, x]))
332332
return false;
333333
}
334334
}
@@ -589,7 +589,7 @@ public override int GetHashCode()
589589
{
590590
for (uint x = 0; x < left.ColumnCount; ++x)
591591
{
592-
if (!FloatingNumber.CheckApproximatelyEqual(left[y, x], right[y, x]))
592+
if (!FloatingNumber.AreApproximatelyEqual(left[y, x], right[y, x]))
593593
return false;
594594
}
595595
}
@@ -617,7 +617,7 @@ public override int GetHashCode()
617617
{
618618
for (uint x = 0; x < left.ColumnCount; ++x)
619619
{
620-
if (!FloatingNumber.CheckApproximatelyEqual(left[y, x], right[y, x]))
620+
if (!FloatingNumber.AreApproximatelyEqual(left[y, x], right[y, x]))
621621
return true;
622622
}
623623
}

SharpMath/Geometry/Point.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public override int GetHashCode()
286286

287287
for (uint i = 0; i < left.Dimension; ++i)
288288
{
289-
if (!FloatingNumber.CheckApproximatelyEqual(left[i], right[i]))
289+
if (!FloatingNumber.AreApproximatelyEqual(left[i], right[i]))
290290
return false;
291291
}
292292

@@ -311,7 +311,7 @@ public override int GetHashCode()
311311

312312
for (uint i = 0; i < left.Dimension; ++i)
313313
{
314-
if (!FloatingNumber.CheckApproximatelyEqual(left[i], right[i]))
314+
if (!FloatingNumber.AreApproximatelyEqual(left[i], right[i]))
315315
return true;
316316
}
317317

SharpMath/Geometry/Point2D.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public override int GetHashCode()
169169

170170
for (uint i = 0; i < 2; ++i)
171171
{
172-
if (!FloatingNumber.CheckApproximatelyEqual(left[i], right[i]))
172+
if (!FloatingNumber.AreApproximatelyEqual(left[i], right[i]))
173173
return false;
174174
}
175175

@@ -191,7 +191,7 @@ public override int GetHashCode()
191191

192192
for (uint i = 0; i < 2; ++i)
193193
{
194-
if (FloatingNumber.CheckApproximatelyEqual(left[i], right[i]))
194+
if (FloatingNumber.AreApproximatelyEqual(left[i], right[i]))
195195
return false;
196196
}
197197

SharpMath/Geometry/Point3D.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public override int GetHashCode()
177177

178178
for (uint i = 0; i < 3; ++i)
179179
{
180-
if (!FloatingNumber.CheckApproximatelyEqual(left[i], right[i]))
180+
if (!FloatingNumber.AreApproximatelyEqual(left[i], right[i]))
181181
return false;
182182
}
183183

@@ -199,7 +199,7 @@ public override int GetHashCode()
199199

200200
for (uint i = 0; i < 3; ++i)
201201
{
202-
if (FloatingNumber.CheckApproximatelyEqual(left[i], right[i]))
202+
if (FloatingNumber.AreApproximatelyEqual(left[i], right[i]))
203203
return false;
204204
}
205205

0 commit comments

Comments
 (0)