Skip to content

Commit

Permalink
Merge pull request #249 from GSharker/dev/guma/rename-geosharkmath
Browse files Browse the repository at this point in the history
Rename GeoSharkMath to GSharkMath.
  • Loading branch information
sonomirco committed Aug 18, 2021
2 parents 0628afe + ca492e4 commit 0de5532
Show file tree
Hide file tree
Showing 54 changed files with 341 additions and 341 deletions.
2 changes: 1 addition & 1 deletion src/GShark.Test.XUnit/Core/KnotVectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void It_Creates_A_Periodic_Uniform_KnotVector()
// Assert
for (int i = 0; i < knots.Count; i++)
{
(expectedKnotVector[i] - knots[i]).Should().BeLessThan(GeoSharkMath.MaxTolerance);
(expectedKnotVector[i] - knots[i]).Should().BeLessThan(GSharkMath.MaxTolerance);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/GShark.Test.XUnit/Core/LinearAlgebraTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void It_Returns_A_Binomial_Coefficient(int n, int k, double resultValue)
double valToCheck = LinearAlgebra.GetBinomial(n, k);

// Assert
(System.Math.Abs(valToCheck - resultValue) < GeoSharkMath.Epsilon).Should().BeTrue();
(System.Math.Abs(valToCheck - resultValue) < GSharkMath.Epsilon).Should().BeTrue();
}
}
}
6 changes: 3 additions & 3 deletions src/GShark.Test.XUnit/Core/MathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public MathTests(ITestOutputHelper testOutput)
[InlineData(180, 3.141593)]
public void It_Returns_The_Radians_From_Degree(double degree, double radiansExpected)
{
System.Math.Round(GeoSharkMath.ToRadians(degree), 6).Should().Be(radiansExpected);
System.Math.Round(GSharkMath.ToRadians(degree), 6).Should().Be(radiansExpected);
}

[Theory]
Expand All @@ -31,7 +31,7 @@ public void It_Returns_The_Radians_From_Degree(double degree, double radiansExpe
[InlineData(3.141592, 180)]
public void It_Returns_The_Degree_From_Radians(double radians, double degreeExpected)
{
System.Math.Round(GeoSharkMath.ToDegrees(radians), 0).Should().Be(degreeExpected);
System.Math.Round(GSharkMath.ToDegrees(radians), 0).Should().Be(degreeExpected);
}

[Theory]
Expand All @@ -44,7 +44,7 @@ public void It_Returns_The_Degree_From_Radians(double radians, double degreeExpe
[InlineData(0.0, true)]
public void It_Checks_If_A_Double_Is_Valid(double val, bool expectedResult)
{
GeoSharkMath.IsValidDouble(val).Should().Be(expectedResult);
GSharkMath.IsValidDouble(val).Should().Be(expectedResult);
}
}
}
32 changes: 16 additions & 16 deletions src/GShark.Test.XUnit/Core/TransformTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void It_Returns_A_Rotated_Transformed_Matrix()
{
// Arrange
var center = new Point3(5, 5, 0);
double angleInRadians = GeoSharkMath.ToRadians(30);
double angleInRadians = GSharkMath.ToRadians(30);

// Act
Transform transform = Transform.Rotation(angleInRadians, center);
Expand All @@ -88,7 +88,7 @@ public void It_Returns_A_Rotated_Transformed_Matrix()
var axis = LinearAlgebra.GetRotationAxis(transform);

// Assert
GeoSharkMath.ToDegrees(angles["Yaw"]).Should().BeApproximately(30, GeoSharkMath.Epsilon);
GSharkMath.ToDegrees(angles["Yaw"]).Should().BeApproximately(30, GSharkMath.Epsilon);
axis.Should().BeEquivalentTo(Vector3.ZAxis);
}

Expand Down Expand Up @@ -139,13 +139,13 @@ public void It_Returns_A_Transformation_Projection_By_A_Plane()
Transform transform = Transform.PlanarProjection(plane);

// Assert
transform[0][0].Should().BeApproximately(0.692308, GeoSharkMath.MaxTolerance);
transform[0][1].Should().BeApproximately(-0.461538, GeoSharkMath.MaxTolerance);
transform[0][3].Should().BeApproximately(1.538462, GeoSharkMath.MaxTolerance);
transform[1][0].Should().BeApproximately(-0.461538, GeoSharkMath.MaxTolerance);
transform[1][1].Should().BeApproximately(0.307692, GeoSharkMath.MaxTolerance);
transform[1][3].Should().BeApproximately(2.307692, GeoSharkMath.MaxTolerance);
transform[3][3].Should().BeApproximately(1.0, GeoSharkMath.MaxTolerance);
transform[0][0].Should().BeApproximately(0.692308, GSharkMath.MaxTolerance);
transform[0][1].Should().BeApproximately(-0.461538, GSharkMath.MaxTolerance);
transform[0][3].Should().BeApproximately(1.538462, GSharkMath.MaxTolerance);
transform[1][0].Should().BeApproximately(-0.461538, GSharkMath.MaxTolerance);
transform[1][1].Should().BeApproximately(0.307692, GSharkMath.MaxTolerance);
transform[1][3].Should().BeApproximately(2.307692, GSharkMath.MaxTolerance);
transform[3][3].Should().BeApproximately(1.0, GSharkMath.MaxTolerance);
}

[Fact]
Expand All @@ -160,13 +160,13 @@ public void It_Returns_A_Plane_To_Plane_Transformation_Matrix()
Transform transform = Transform.PlaneToPlane(Plane.PlaneXY, plane);

// Assert
transform[0][0].Should().BeApproximately(-0.832050, GeoSharkMath.MaxTolerance);
transform[0][2].Should().BeApproximately(-0.554700, GeoSharkMath.MaxTolerance);
transform[0][3].Should().BeApproximately(5.0, GeoSharkMath.MaxTolerance);
transform[1][0].Should().BeApproximately(0.554700, GeoSharkMath.MaxTolerance);
transform[1][2].Should().BeApproximately(-0.832050, GeoSharkMath.MaxTolerance);
transform[2][1].Should().BeApproximately(-1.0, GeoSharkMath.MaxTolerance);
transform[3][3].Should().BeApproximately(1.0, GeoSharkMath.MaxTolerance);
transform[0][0].Should().BeApproximately(-0.832050, GSharkMath.MaxTolerance);
transform[0][2].Should().BeApproximately(-0.554700, GSharkMath.MaxTolerance);
transform[0][3].Should().BeApproximately(5.0, GSharkMath.MaxTolerance);
transform[1][0].Should().BeApproximately(0.554700, GSharkMath.MaxTolerance);
transform[1][2].Should().BeApproximately(-0.832050, GSharkMath.MaxTolerance);
transform[2][1].Should().BeApproximately(-1.0, GSharkMath.MaxTolerance);
transform[3][3].Should().BeApproximately(1.0, GSharkMath.MaxTolerance);
}
}
}
4 changes: 2 additions & 2 deletions src/GShark.Test.XUnit/Core/TrigonometryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void It_Returns_The_Closest_Point_On_A_Segment(double[] ptToCheck, double
(double tValue, Point3 pt) closestPt = Trigonometry.ClosestPointToSegment(testPt, pt0, pt1, 0, 1);

// Assert
closestPt.tValue.Should().BeApproximately(tValExpected, GeoSharkMath.MaxTolerance);
closestPt.pt.EpsilonEquals(expectedPt, GeoSharkMath.Epsilon).Should().BeTrue();
closestPt.tValue.Should().BeApproximately(tValExpected, GSharkMath.MaxTolerance);
closestPt.pt.EpsilonEquals(expectedPt, GSharkMath.Epsilon).Should().BeTrue();
}
}
}
20 changes: 10 additions & 10 deletions src/GShark.Test.XUnit/Geometry/ArcTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ArcTests(ITestOutputHelper testOutput)

#region example
// Initializes an arc by plane, radius and angle.
double angle = GeoSharkMath.ToRadians(40);
double angle = GSharkMath.ToRadians(40);
_exampleArc2D = new Arc(Plane.PlaneXY, 15, angle);

// Initializes an arc by 3 points.
Expand All @@ -38,10 +38,10 @@ public void Initializes_An_Arc()

// Assert
arc.Should().NotBeNull();
arc.Length.Should().BeApproximately(10.471976, GeoSharkMath.MaxTolerance);
arc.Length.Should().BeApproximately(10.471976, GSharkMath.MaxTolerance);
arc.Center.Should().BeEquivalentTo(Plane.PlaneXY.Origin);
arc.Radius.Should().Be(15);
arc.Angle.Should().BeApproximately(0.698132, GeoSharkMath.MaxTolerance);
arc.Angle.Should().BeApproximately(0.698132, GSharkMath.MaxTolerance);
}

[Fact]
Expand All @@ -51,9 +51,9 @@ public void Initializes_An_Arc_By_Three_Points()
Arc arc = _exampleArc3D;

// Assert
arc.Length.Should().BeApproximately(71.333203, GeoSharkMath.MaxTolerance);
arc.Radius.Should().BeApproximately(16.47719, GeoSharkMath.MaxTolerance);
GeoSharkMath.ToDegrees(arc.Angle).Should().BeApproximately(248.045414, GeoSharkMath.MaxTolerance);
arc.Length.Should().BeApproximately(71.333203, GSharkMath.MaxTolerance);
arc.Radius.Should().BeApproximately(16.47719, GSharkMath.MaxTolerance);
GSharkMath.ToDegrees(arc.Angle).Should().BeApproximately(248.045414, GSharkMath.MaxTolerance);
}

[Fact]
Expand All @@ -70,14 +70,14 @@ public void Initializes_An_Arc_By_Two_Points_And_A_Direction()
// Assert
arc.StartPoint.EpsilonEquals(pt1, 1e-6).Should().BeTrue();
arc.EndPoint.EpsilonEquals(pt2, 1e-6).Should().BeTrue();
arc.Radius.Should().BeApproximately(12.247449, GeoSharkMath.MaxTolerance);
arc.Radius.Should().BeApproximately(12.247449, GSharkMath.MaxTolerance);
}

[Fact]
public void It_Returns_The_BoundingBox_Of_The_Arc()
{
// Arrange
double angle = GeoSharkMath.ToRadians(40);
double angle = GSharkMath.ToRadians(40);
Arc arc2D = new Arc(Plane.PlaneXY, 15, angle);
Arc arc3D = _exampleArc3D;

Expand Down Expand Up @@ -220,7 +220,7 @@ public void It_Is_A_Curve_Representation_Of_ExampleArc3D()

for (int i = 0; i < ptChecks.Length; i++)
{
arc.LocationPoints[i].EpsilonEquals(ptChecks[i], GeoSharkMath.MaxTolerance).Should().BeTrue();
arc.LocationPoints[i].EpsilonEquals(ptChecks[i], GSharkMath.MaxTolerance).Should().BeTrue();
arc.ControlPoints[i].W.Should().Be(weightChecks[i]);

if (i < 3)
Expand All @@ -247,7 +247,7 @@ public void It_Returns_A_Arc_Based_On_A_Start_And_An_End_Point_And_A_Direction()
Point3 endPt = new Point3(10, 15, 10);
Vector3 dir = new Vector3(3, 3, 0);
double radiusExpected = 12.247449;
double angleExpected = GeoSharkMath.ToRadians(60);
double angleExpected = GSharkMath.ToRadians(60);
Point3 centerExpected = new Point3(0, 10, 15);

// Act
Expand Down
6 changes: 3 additions & 3 deletions src/GShark.Test.XUnit/Geometry/BoundingBoxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void It_Creates_A_BoundingBox_From_Points(Point3[] pts, Point3 min, Point
public void It_Creates_An_Aligned_BoundingBox()
{
// Arrange
Plane orientedPlane = Plane.PlaneXY.Rotate(GeoSharkMath.ToRadians(30));
Plane orientedPlane = Plane.PlaneXY.Rotate(GSharkMath.ToRadians(30));
var expectedMin = new Point3(45.662928, 59.230957, -4.22451);
var expectedMax = new Point3(77.622297, 78.520011, 3.812853);

Expand All @@ -45,8 +45,8 @@ public void It_Creates_An_Aligned_BoundingBox()
// Assert
_testOutput.WriteLine(bBox.ToString());
bBox.Should().NotBeNull();
bBox.Min.DistanceTo(expectedMin).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox.Max.DistanceTo(expectedMax).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox.Min.DistanceTo(expectedMin).Should().BeLessThan(GSharkMath.MaxTolerance);
bBox.Max.DistanceTo(expectedMax).Should().BeLessThan(GSharkMath.MaxTolerance);
}

[Fact]
Expand Down
12 changes: 6 additions & 6 deletions src/GShark.Test.XUnit/Geometry/CircleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void It_Returns_A_Circle3D_With_Its_Nurbs_Representation()
// Assert
for (int ptIndex = 0; ptIndex < ptsExpected.Count; ptIndex++)
{
ctrPts[ptIndex].EpsilonEquals(ptsExpected[ptIndex], GeoSharkMath.MaxTolerance);
ctrPts[ptIndex].EpsilonEquals(ptsExpected[ptIndex], GSharkMath.MaxTolerance);
}
}

Expand Down Expand Up @@ -104,7 +104,7 @@ public void It_Returns_The_Point_On_The_Circle_At_The_Give_Parameter_T(double t,
Point3 pt = circle.PointAt(t);

// Assert
pt.EpsilonEquals(expectedPt, GeoSharkMath.MaxTolerance).Should().BeTrue();
pt.EpsilonEquals(expectedPt, GSharkMath.MaxTolerance).Should().BeTrue();
}

[Theory]
Expand All @@ -120,7 +120,7 @@ public void It_Returns_The_Tangent_At_The_Give_Parameter_T(double t, double[] pt
Point3 tangent = circle.TangentAt(t);

// Assert
tangent.EpsilonEquals(expectedTangent, GeoSharkMath.MaxTolerance).Should().BeTrue();
tangent.EpsilonEquals(expectedTangent, GSharkMath.MaxTolerance).Should().BeTrue();
}

[Fact]
Expand All @@ -135,8 +135,8 @@ public void It_Returns_The_Bounding_Box_Of_The_Circle()
BoundingBox bBox = circle.BoundingBox;

// Assert
bBox.Min.EpsilonEquals(minCheck, GeoSharkMath.MaxTolerance).Should().BeTrue();
bBox.Max.EpsilonEquals(maxCheck, GeoSharkMath.MaxTolerance).Should().BeTrue();
bBox.Min.EpsilonEquals(minCheck, GSharkMath.MaxTolerance).Should().BeTrue();
bBox.Max.EpsilonEquals(maxCheck, GSharkMath.MaxTolerance).Should().BeTrue();
}

[Theory]
Expand All @@ -153,7 +153,7 @@ public void It_Returns_The_Closest_Point_On_A_Circle(double[] ptToTest, double[]
Point3 pt = circle.ClosestPoint(testPt);

// Assert
pt.EpsilonEquals(expectedPt, GeoSharkMath.MaxTolerance).Should().BeTrue();
pt.EpsilonEquals(expectedPt, GSharkMath.MaxTolerance).Should().BeTrue();
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/GShark.Test.XUnit/Geometry/LineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void It_Returns_The_Evaluated_Point_At_The_Given_Parameter(double t, doub
Point3 ptEvaluated = _exampleLine.PointAt(t);

// Assert
ptEvaluated.EpsilonEquals(expectedPt, GeoSharkMath.Epsilon).Should().BeTrue();
ptEvaluated.EpsilonEquals(expectedPt, GSharkMath.Epsilon).Should().BeTrue();

}

Expand All @@ -179,7 +179,7 @@ public void It_Returns_The_Parameter_On_The_Line_Closest_To_The_Point(double exp
double parameter = _exampleLine.ClosestParameter(pt);

// Assert
parameter.Should().BeApproximately(expectedParam, GeoSharkMath.MaxTolerance);
parameter.Should().BeApproximately(expectedParam, GSharkMath.MaxTolerance);
}

[Fact]
Expand All @@ -200,7 +200,7 @@ public void It_Returns_An_Extend_Line()
Line extendedLine = _exampleLine.Extend(0, -5);

// Assert
extendedLine.Length.Should().BeApproximately(13.027756, GeoSharkMath.MaxTolerance);
extendedLine.Length.Should().BeApproximately(13.027756, GSharkMath.MaxTolerance);
extendedLine.Start.Should().BeEquivalentTo(_exampleLine.Start);
}

Expand Down
28 changes: 14 additions & 14 deletions src/GShark.Test.XUnit/Geometry/NurbsCurveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public void It_Returns_A_Closed_NurbsCurve()

// Assert
nurbsCurve.ControlPoints.Count.Should().Be(5);
nurbsCurve.LocationPoints[1].DistanceTo(nurbsCurve.LocationPoints[^1]).Should().BeLessThan(GeoSharkMath.Epsilon);
nurbsCurve.LocationPoints[1].DistanceTo(nurbsCurve.LocationPoints[^1]).Should().BeLessThan(GSharkMath.Epsilon);
nurbsCurve.Knots.Count.Should().Be(8);
nurbsCurve.Domain.T0.Should().Be(0.0);
nurbsCurve.Domain.T1.Should().Be(1.0);
expectedPt00.DistanceTo(ptAt00).Should().BeLessThan(GeoSharkMath.Epsilon);
expectedPt01.DistanceTo(ptAt01).Should().BeLessThan(GeoSharkMath.Epsilon);
expectedPt00.DistanceTo(ptAt00).Should().BeLessThan(GSharkMath.Epsilon);
expectedPt01.DistanceTo(ptAt01).Should().BeLessThan(GSharkMath.Epsilon);
}

[Fact]
Expand Down Expand Up @@ -129,11 +129,11 @@ public void It_Returns_The_Bounding_Box_Of_A_Planar_Curve()
BoundingBox bBox1 = crv1.BoundingBox;

// Assert
bBox0.Max.DistanceTo(expectedPtMax0).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox0.Min.DistanceTo(expectedPtMin0).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox0.Max.DistanceTo(expectedPtMax0).Should().BeLessThan(GSharkMath.MaxTolerance);
bBox0.Min.DistanceTo(expectedPtMin0).Should().BeLessThan(GSharkMath.MaxTolerance);

bBox1.Max.DistanceTo(expectedPtMax1).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox1.Min.DistanceTo(expectedPtMin1).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox1.Max.DistanceTo(expectedPtMax1).Should().BeLessThan(GSharkMath.MaxTolerance);
bBox1.Min.DistanceTo(expectedPtMin1).Should().BeLessThan(GSharkMath.MaxTolerance);
}

[Fact]
Expand All @@ -154,11 +154,11 @@ public void It_Returns_The_Bounding_Box_Of_A_3D_Nurbs_Curve()
BoundingBox bBox1 = crv1.BoundingBox;

// Assert
bBox0.Max.DistanceTo(expectedPtMax0).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox0.Min.DistanceTo(expectedPtMin0).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox0.Max.DistanceTo(expectedPtMax0).Should().BeLessThan(GSharkMath.MaxTolerance);
bBox0.Min.DistanceTo(expectedPtMin0).Should().BeLessThan(GSharkMath.MaxTolerance);

bBox1.Max.DistanceTo(expectedPtMax1).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox1.Min.DistanceTo(expectedPtMin1).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox1.Max.DistanceTo(expectedPtMax1).Should().BeLessThan(GSharkMath.MaxTolerance);
bBox1.Min.DistanceTo(expectedPtMin1).Should().BeLessThan(GSharkMath.MaxTolerance);
}

[Fact]
Expand All @@ -172,8 +172,8 @@ public void It_Returns_The_Bounding_Box_Of_A_Periodic_Curve()
BoundingBox bBox = NurbsCurveCollection.PeriodicClosedNurbsCurve().BoundingBox;

// Assert
bBox.Max.DistanceTo(expectedPtMax).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox.Min.DistanceTo(expectedPtMin).Should().BeLessThan(GeoSharkMath.MaxTolerance);
bBox.Max.DistanceTo(expectedPtMax).Should().BeLessThan(GSharkMath.MaxTolerance);
bBox.Min.DistanceTo(expectedPtMin).Should().BeLessThan(GSharkMath.MaxTolerance);
}

[Fact]
Expand Down Expand Up @@ -216,7 +216,7 @@ public void It_Returns_A_NurbsCurve_With_Clamped_End()
// Assert
curveClamped.Knots.IsClamped(curveClamped.Degree).Should().BeTrue();
curveClamped.ControlPoints[0]
.EpsilonEquals(curveClamped.ControlPoints[^1], GeoSharkMath.MaxTolerance)
.EpsilonEquals(curveClamped.ControlPoints[^1], GSharkMath.MaxTolerance)
.Should().BeTrue();
curve.ControlPoints[2].Should().BeEquivalentTo(curveClamped.ControlPoints[2]);
curve.ControlPoints[^3].Should().BeEquivalentTo(curveClamped.ControlPoints[^3]);
Expand Down
Loading

0 comments on commit 0de5532

Please sign in to comment.