diff --git a/src/cs/MonoGame.Extended/Math/OrientedBoundingRectangle.cs b/src/cs/MonoGame.Extended/Math/OrientedRectangle.cs
similarity index 70%
rename from src/cs/MonoGame.Extended/Math/OrientedBoundingRectangle.cs
rename to src/cs/MonoGame.Extended/Math/OrientedRectangle.cs
index 14c52f47..e1911b62 100644
--- a/src/cs/MonoGame.Extended/Math/OrientedBoundingRectangle.cs
+++ b/src/cs/MonoGame.Extended/Math/OrientedRectangle.cs
@@ -13,22 +13,22 @@ namespace MonoGame.Extended
///
///
[DebuggerDisplay($"{{{nameof(DebugDisplayString)},nq}}")]
- public struct OrientedBoundingRectangle : IEquatable, IShapeF
+ public struct OrientedRectangle : IEquatable, IShapeF
{
///
- /// The centre position of this .
+ /// The centre position of this .
///
public Point2 Center;
///
/// The distance from the point along both axes to any point on the boundary of this
- /// .
+ /// .
///
///
public Vector2 Radii;
///
- /// The rotation matrix of the bounding rectangle .
+ /// The rotation matrix of the bounding rectangle .
///
public Matrix2 Orientation;
@@ -39,7 +39,7 @@ namespace MonoGame.Extended
/// The centre .
/// The radii .
/// The orientation .
- public OrientedBoundingRectangle(Point2 center, Size2 radii, Matrix2 orientation)
+ public OrientedRectangle(Point2 center, Size2 radii, Matrix2 orientation)
{
Center = center;
Radii = radii;
@@ -77,76 +77,76 @@ namespace MonoGame.Extended
public RectangleF BoundingRectangle => (RectangleF)this;
///
- /// Computes the from the specified
+ /// Computes the from the specified
/// transformed by .
///
- /// The to transform.
+ /// The to transform.
/// The transformation.
- /// A new .
- public static OrientedBoundingRectangle Transform(OrientedBoundingRectangle rectangle, ref Matrix2 transformMatrix)
+ /// A new .
+ public static OrientedRectangle Transform(OrientedRectangle rectangle, ref Matrix2 transformMatrix)
{
Transform(ref rectangle, ref transformMatrix, out var result);
return result;
}
-
- private static void Transform(ref OrientedBoundingRectangle rectangle, ref Matrix2 transformMatrix, out OrientedBoundingRectangle result)
+
+ private static void Transform(ref OrientedRectangle rectangle, ref Matrix2 transformMatrix, out OrientedRectangle result)
{
- PrimitivesHelper.TransformOrientedBoundingRectangle(
+ PrimitivesHelper.TransformOrientedRectangle(
ref rectangle.Center,
ref rectangle.Orientation,
ref transformMatrix);
- result = new OrientedBoundingRectangle();
+ result = new OrientedRectangle();
result.Center = rectangle.Center;
result.Radii = rectangle.Radii;
result.Orientation = rectangle.Orientation;
}
///
- /// Compares to two structures. The result specifies whether the
+ /// Compares to two structures. The result specifies whether the
/// the values of the , and are
/// equal.
///
- /// The left .
- /// The right .
+ /// The left .
+ /// The right .
/// true if left and right argument are equal; otherwise, false.
- public static bool operator ==(OrientedBoundingRectangle left, OrientedBoundingRectangle right)
+ public static bool operator ==(OrientedRectangle left, OrientedRectangle right)
{
return left.Equals(right);
}
///
- /// Compares to two structures. The result specifies whether the
+ /// Compares to two structures. The result specifies whether the
/// the values of the , or are
/// unequal.
///
- /// The left .
- /// The right .
+ /// The left .
+ /// The right .
/// true if left and right argument are unequal; otherwise, false.
- public static bool operator !=(OrientedBoundingRectangle left, OrientedBoundingRectangle right)
+ public static bool operator !=(OrientedRectangle left, OrientedRectangle right)
{
return !left.Equals(right);
}
///
- /// Determines whether two instances of are equal.
+ /// Determines whether two instances of are equal.
///
- /// The other .
- /// true if the specified is equal
- /// to the current ; otherwise, false.
- public bool Equals(OrientedBoundingRectangle other)
+ /// The other .
+ /// true if the specified is equal
+ /// to the current ; otherwise, false.
+ public bool Equals(OrientedRectangle other)
{
return Center.Equals(other.Center) && Radii.Equals(other.Radii) && Orientation.Equals(other.Orientation);
}
///
- /// Determines whether two instances of are equal.
+ /// Determines whether two instances of are equal.
///
- /// The to compare to.
- /// true if the specified is equal
- /// to the current ; otherwise, false.
+ /// The to compare to.
+ /// true if the specified is equal
+ /// to the current ; otherwise, false.
public override bool Equals(object obj)
{
- return obj is OrientedBoundingRectangle other && Equals(other);
+ return obj is OrientedRectangle other && Equals(other);
}
///
@@ -159,23 +159,23 @@ namespace MonoGame.Extended
}
///
- /// Performs an implicit conversion from a to .
+ /// Performs an implicit conversion from a to .
///
/// The rectangle to convert.
- /// The resulting .
- public static explicit operator OrientedBoundingRectangle(RectangleF rectangle)
+ /// The resulting .
+ public static explicit operator OrientedRectangle(RectangleF rectangle)
{
var radii = new Size2(rectangle.Width * 0.5f, rectangle.Height * 0.5f);
var centre = new Point2(rectangle.X + radii.Width, rectangle.Y + radii.Height);
- return new OrientedBoundingRectangle(centre, radii, Matrix2.Identity);
+ return new OrientedRectangle(centre, radii, Matrix2.Identity);
}
- public static explicit operator RectangleF(OrientedBoundingRectangle orientedBoundingRectangle)
+ public static explicit operator RectangleF(OrientedRectangle orientedRectangle)
{
- var topLeft = orientedBoundingRectangle.Center - orientedBoundingRectangle.Radii;
- var rectangle = new RectangleF(topLeft, orientedBoundingRectangle.Radii * 2);
- return RectangleF.Transform(rectangle, ref orientedBoundingRectangle.Orientation);
+ var topLeft = orientedRectangle.Center - orientedRectangle.Radii;
+ var rectangle = new RectangleF(topLeft, orientedRectangle.Radii * 2);
+ return RectangleF.Transform(rectangle, ref orientedRectangle.Orientation);
}
///
@@ -185,7 +185,7 @@ namespace MonoGame.Extended
///
///
///
- public static bool Intersects(OrientedBoundingRectangle rectangle, OrientedBoundingRectangle other)
+ public static bool Intersects(OrientedRectangle rectangle, OrientedRectangle other)
{
var corners = rectangle.Points;
var otherCorners = other.Points;
@@ -248,10 +248,10 @@ namespace MonoGame.Extended
}
///
- /// Returns a that represents this .
+ /// Returns a that represents this .
///
///
- /// A that represents this .
+ /// A that represents this .
///
public override string ToString()
{
diff --git a/src/cs/MonoGame.Extended/Math/PrimitivesHelper.cs b/src/cs/MonoGame.Extended/Math/PrimitivesHelper.cs
index 63152f16..ed082708 100644
--- a/src/cs/MonoGame.Extended/Math/PrimitivesHelper.cs
+++ b/src/cs/MonoGame.Extended/Math/PrimitivesHelper.cs
@@ -72,7 +72,7 @@ namespace MonoGame.Extended
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal static void TransformOrientedBoundingRectangle(
+ internal static void TransformOrientedRectangle(
ref Point2 center,
ref Matrix2 orientation,
ref Matrix2 transformMatrix)
diff --git a/src/cs/MonoGame.Extended/Math/ShapeF.cs b/src/cs/MonoGame.Extended/Math/ShapeF.cs
index fe1dca76..979477f3 100644
--- a/src/cs/MonoGame.Extended/Math/ShapeF.cs
+++ b/src/cs/MonoGame.Extended/Math/ShapeF.cs
@@ -38,7 +38,7 @@ namespace MonoGame.Extended
{
CircleF circleA => IntersectsInternal(circleA, shapeB),
RectangleF rectangleA => IntersectsInternal(rectangleA, shapeB),
- OrientedBoundingRectangle orientedBoundingRectangleA => IntersectsInternal(orientedBoundingRectangleA, shapeB),
+ OrientedRectangle orientedRectangleA => IntersectsInternal(orientedRectangleA, shapeB),
_ => throw new ArgumentOutOfRangeException(nameof(shapeA))
};
}
@@ -49,7 +49,7 @@ namespace MonoGame.Extended
{
CircleF otherCircle => CircleF.Intersects(circle, otherCircle),
RectangleF otherRectangle => Intersects(circle, otherRectangle),
- OrientedBoundingRectangle otherOrientedBoundingRectangle => Intersects(circle, otherOrientedBoundingRectangle),
+ OrientedRectangle otherOrientedRectangle => Intersects(circle, otherOrientedRectangle),
_ => throw new ArgumentOutOfRangeException(nameof(shape))
};
}
@@ -60,18 +60,18 @@ namespace MonoGame.Extended
{
CircleF otherCircle => Intersects(otherCircle, rectangle),
RectangleF otherRectangle => RectangleF.Intersects(rectangle, otherRectangle),
- OrientedBoundingRectangle otherOrientedBoundingRectangle => Intersects(rectangle, otherOrientedBoundingRectangle),
+ OrientedRectangle otherOrientedRectangle => Intersects(rectangle, otherOrientedRectangle),
_ => throw new ArgumentOutOfRangeException(nameof(shape))
};
}
- private static bool IntersectsInternal(OrientedBoundingRectangle orientedBoundingRectangle, IShapeF shape)
+ private static bool IntersectsInternal(OrientedRectangle orientedRectangle, IShapeF shape)
{
return shape switch
{
- CircleF circleB => Intersects(circleB, orientedBoundingRectangle),
- RectangleF rectangleB => Intersects(rectangleB, orientedBoundingRectangle),
- OrientedBoundingRectangle orientedBoundingRectangleB => OrientedBoundingRectangle.Intersects(orientedBoundingRectangle, orientedBoundingRectangleB),
+ CircleF circleB => Intersects(circleB, orientedRectangle),
+ RectangleF rectangleB => Intersects(rectangleB, orientedRectangle),
+ OrientedRectangle orientedRectangleB => OrientedRectangle.Intersects(orientedRectangle, orientedRectangleB),
_ => throw new ArgumentOutOfRangeException(nameof(shape))
};
}
@@ -89,30 +89,30 @@ namespace MonoGame.Extended
}
///
- /// Checks whether a and intersects.
+ /// Checks whether a and intersects.
///
/// to use in intersection test.
- /// to use in intersection test.
+ /// to use in intersection test.
/// True if the circle and oriented bounded rectangle intersects, otherwise false.
- public static bool Intersects(CircleF circle, OrientedBoundingRectangle orientedBoundingRectangle)
+ public static bool Intersects(CircleF circle, OrientedRectangle orientedRectangle)
{
- var rotation = Matrix2.CreateRotationZ(-orientedBoundingRectangle.Orientation.Rotation);
- var circleCenterInRectangleSpace = rotation.Transform(circle.Center - orientedBoundingRectangle.Center);
+ var rotation = Matrix2.CreateRotationZ(-orientedRectangle.Orientation.Rotation);
+ var circleCenterInRectangleSpace = rotation.Transform(circle.Center - orientedRectangle.Center);
var circleInRectangleSpace = new CircleF(circleCenterInRectangleSpace, circle.Radius);
- var rectangleInLocalSpace = OrientedBoundingRectangle.Transform(orientedBoundingRectangle, ref rotation);
+ var rectangleInLocalSpace = OrientedRectangle.Transform(orientedRectangle, ref rotation);
var boundingRectangle = new BoundingRectangle(rectangleInLocalSpace.Center, rectangleInLocalSpace.Radii);
return circleInRectangleSpace.Intersects(boundingRectangle);
}
///
- /// Checks if a and intersects.
+ /// Checks if a and intersects.
///
///
- ///
+ ///
/// True if objects are intersecting, otherwise false.
- public static bool Intersects(RectangleF rectangleF, OrientedBoundingRectangle orientedBoundingRectangle)
+ public static bool Intersects(RectangleF rectangleF, OrientedRectangle orientedRectangle)
{
- return OrientedBoundingRectangle.Intersects(orientedBoundingRectangle, (OrientedBoundingRectangle)rectangleF);
+ return OrientedRectangle.Intersects(orientedRectangle, (OrientedRectangle)rectangleF);
}
}
}
diff --git a/src/cs/Tests/MonoGame.Extended.Tests/Primitives/OrientedBoundingRectangleTests.cs b/src/cs/Tests/MonoGame.Extended.Tests/Primitives/OrientedRectangleTests.cs
similarity index 71%
rename from src/cs/Tests/MonoGame.Extended.Tests/Primitives/OrientedBoundingRectangleTests.cs
rename to src/cs/Tests/MonoGame.Extended.Tests/Primitives/OrientedRectangleTests.cs
index be64af4a..e3b40c8c 100644
--- a/src/cs/Tests/MonoGame.Extended.Tests/Primitives/OrientedBoundingRectangleTests.cs
+++ b/src/cs/Tests/MonoGame.Extended.Tests/Primitives/OrientedRectangleTests.cs
@@ -5,12 +5,12 @@ using Vector2 = Microsoft.Xna.Framework.Vector2;
namespace MonoGame.Extended.Tests.Primitives;
-public class OrientedBoundingRectangleTests
+public class OrientedRectangleTests
{
[Fact]
- public void Initializes_oriented_bounding_rectangle()
+ public void Initializes_oriented_rectangle()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(1, 2), new Size2(3, 4), new Matrix2(5, 6, 7, 8, 9, 10));
+ var rectangle = new OrientedRectangle(new Point2(1, 2), new Size2(3, 4), new Matrix2(5, 6, 7, 8, 9, 10));
Assert.Equal(new Point2(1, 2), rectangle.Center);
Assert.Equal(new Vector2(3, 4), rectangle.Radii);
@@ -31,21 +31,21 @@ public class OrientedBoundingRectangleTests
new object[]
{
"empty compared with empty is true",
- new OrientedBoundingRectangle(Point2.Zero, Size2.Empty, Matrix2.Identity),
- new OrientedBoundingRectangle(Point2.Zero, Size2.Empty, Matrix2.Identity)
+ new OrientedRectangle(Point2.Zero, Size2.Empty, Matrix2.Identity),
+ new OrientedRectangle(Point2.Zero, Size2.Empty, Matrix2.Identity)
},
new object[]
{
"initialized compared with initialized true",
- new OrientedBoundingRectangle(new Point2(1, 2), new Size2(3, 4), new Matrix2(5, 6, 7, 8, 9, 10)),
- new OrientedBoundingRectangle(new Point2(1, 2), new Size2(3, 4), new Matrix2(5, 6, 7, 8, 9, 10))
+ new OrientedRectangle(new Point2(1, 2), new Size2(3, 4), new Matrix2(5, 6, 7, 8, 9, 10)),
+ new OrientedRectangle(new Point2(1, 2), new Size2(3, 4), new Matrix2(5, 6, 7, 8, 9, 10))
}
};
[Theory]
[MemberData(nameof(_equalsComparisons))]
#pragma warning disable xUnit1026
- public void Equals_comparison(string name, OrientedBoundingRectangle first, OrientedBoundingRectangle second)
+ public void Equals_comparison(string name, OrientedRectangle first, OrientedRectangle second)
#pragma warning restore xUnit1026
{
Assert.True(first == second);
@@ -57,10 +57,10 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Center_point_is_not_translated()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(1, 2), new Size2(), Matrix2.Identity);
+ var rectangle = new OrientedRectangle(new Point2(1, 2), new Size2(), Matrix2.Identity);
var transform = Matrix2.Identity;
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(1, 2), result.Center);
}
@@ -68,10 +68,10 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Center_point_is_translated()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(0, 0), new Size2(), new Matrix2());
+ var rectangle = new OrientedRectangle(new Point2(0, 0), new Size2(), new Matrix2());
var transform = Matrix2.CreateTranslation(1, 2);
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(1, 2), result.Center);
}
@@ -79,10 +79,10 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Radii_is_not_changed_by_identity_transform()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(), new Size2(10, 20), new Matrix2());
+ var rectangle = new OrientedRectangle(new Point2(), new Size2(10, 20), new Matrix2());
var transform = Matrix2.Identity;
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Vector2(10, 20), result.Radii);
}
@@ -90,10 +90,10 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Radii_is_not_changed_by_translation()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(1, 2), new Size2(10, 20), new Matrix2());
+ var rectangle = new OrientedRectangle(new Point2(1, 2), new Size2(10, 20), new Matrix2());
var transform = Matrix2.CreateTranslation(1, 2);
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Vector2(10, 20), result.Radii);
}
@@ -101,10 +101,10 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Orientation_is_rotated_45_degrees_left()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(), new Size2(), Matrix2.Identity);
+ var rectangle = new OrientedRectangle(new Point2(), new Size2(), Matrix2.Identity);
var transform = Matrix2.CreateRotationZ(MathHelper.PiOver4);
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(), result.Center);
Assert.Equal(new Vector2(), result.Radii);
@@ -114,11 +114,11 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Orientation_is_rotated_to_45_degrees_from_180()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(), new Size2(), Matrix2.CreateRotationZ(MathHelper.Pi));
+ var rectangle = new OrientedRectangle(new Point2(), new Size2(), Matrix2.CreateRotationZ(MathHelper.Pi));
var transform = Matrix2.CreateRotationZ(-3 * MathHelper.PiOver4);
var expectedOrientation = Matrix2.CreateRotationZ(MathHelper.PiOver4);
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(new Point2(), result.Center);
Assert.Equal(new Vector2(), result.Radii);
@@ -133,10 +133,10 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Points_are_same_as_center()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(1, 2), new Size2(), Matrix2.Identity);
+ var rectangle = new OrientedRectangle(new Point2(1, 2), new Size2(), Matrix2.Identity);
var transform = Matrix2.Identity;
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
CollectionAssert.Equal(
new List
@@ -152,10 +152,10 @@ public class OrientedBoundingRectangleTests
[Fact]
public void Points_are_translated()
{
- var rectangle = new OrientedBoundingRectangle(new Point2(0, 0), new Size2(2, 4), Matrix2.Identity);
+ var rectangle = new OrientedRectangle(new Point2(0, 0), new Size2(2, 4), Matrix2.Identity);
var transform = Matrix2.CreateTranslation(10, 20);
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
CollectionAssert.Equal(
new List
@@ -207,13 +207,13 @@ public class OrientedBoundingRectangleTests
* :
* :
*/
- var rectangle = new OrientedBoundingRectangle(new Point2(1, 2), new Size2(2, 4), Matrix2.Identity);
+ var rectangle = new OrientedRectangle(new Point2(1, 2), new Size2(2, 4), Matrix2.Identity);
var transform =
Matrix2.CreateRotationZ(MathHelper.PiOver2)
*
Matrix2.CreateTranslation(10, 20);
- var result = OrientedBoundingRectangle.Transform(rectangle, ref transform);
+ var result = OrientedRectangle.Transform(rectangle, ref transform);
Assert.Equal(8, result.Center.X, 6);
Assert.Equal(21, result.Center.Y, 6);
diff --git a/src/cs/Tests/MonoGame.Extended.Tests/Primitives/ShapeTests.cs b/src/cs/Tests/MonoGame.Extended.Tests/Primitives/ShapeTests.cs
index f310d54e..dcc6f3af 100644
--- a/src/cs/Tests/MonoGame.Extended.Tests/Primitives/ShapeTests.cs
+++ b/src/cs/Tests/MonoGame.Extended.Tests/Primitives/ShapeTests.cs
@@ -85,7 +85,7 @@ public class ShapeTests
}
}
- public class OrientedBoundingRectangleTests
+ public class OrientedRectangleTests
{
[Fact]
public void Axis_aligned_rectangle_intersects_circle()
@@ -99,7 +99,7 @@ public class ShapeTests
* :
* :
*/
- IShapeF rectangle = new OrientedBoundingRectangle(Point2.Zero, new Size2(1, 1), Matrix2.Identity);
+ IShapeF rectangle = new OrientedRectangle(Point2.Zero, new Size2(1, 1), Matrix2.Identity);
var circle = new CircleF(Point2.Zero, 1);
Assert.True(rectangle.Intersects(circle));
@@ -117,7 +117,7 @@ public class ShapeTests
* :
* :
*/
- IShapeF rectangle = new OrientedBoundingRectangle(Point2.Zero, new Size2(1, 1), Matrix2.Identity);
+ IShapeF rectangle = new OrientedRectangle(Point2.Zero, new Size2(1, 1), Matrix2.Identity);
var circle = new CircleF(new Point2(-2, 1), .99f);
Assert.False(rectangle.Intersects(circle));
@@ -135,7 +135,7 @@ public class ShapeTests
* * *
* :* *
*/
- IShapeF rectangle = new OrientedBoundingRectangle(new Point2(-1, 1), new Size2(2.8f, 2.8f), Matrix2.CreateRotationZ(MathHelper.PiOver4));
+ IShapeF rectangle = new OrientedRectangle(new Point2(-1, 1), new Size2(2.8f, 2.8f), Matrix2.CreateRotationZ(MathHelper.PiOver4));
var circle = new CircleF(new Point2(1, -1), 1.4f);
Assert.False(rectangle.Intersects(circle));
@@ -153,7 +153,7 @@ public class ShapeTests
* :**
* :
*/
- IShapeF rectangle = new OrientedBoundingRectangle(new Point2(-1, 0), new Size2(1, 1), Matrix2.Identity);
+ IShapeF rectangle = new OrientedRectangle(new Point2(-1, 0), new Size2(1, 1), Matrix2.Identity);
var rect = new RectangleF(new Point2(0.001f, 0), new Size2(2, 2));
Assert.False(rectangle.Intersects(rect));
@@ -171,7 +171,7 @@ public class ShapeTests
* :**
* :
*/
- IShapeF rectangle = new OrientedBoundingRectangle(new Point2(-1, 0), new Size2(1, 1), Matrix2.Identity);
+ IShapeF rectangle = new OrientedRectangle(new Point2(-1, 0), new Size2(1, 1), Matrix2.Identity);
var rect = new RectangleF(new Point2(0, 0), new Size2(2, 2));
Assert.True(rectangle.Intersects(rect));