diff --git a/Source/OpenTK/Math/Box2.cs b/Source/OpenTK/Math/Box2.cs
index cf2d3906..70751981 100644
--- a/Source/OpenTK/Math/Box2.cs
+++ b/Source/OpenTK/Math/Box2.cs
@@ -99,40 +99,6 @@ namespace OpenTK
return FromDimensions(position.X, position.Y, size.X, size.Y);
}
- ///
- /// Creates a new Box2 from the specified corners.
- ///
- /// One of the corners of the box.
- /// The opposite corner of the box.
- ///
- public static Box2 FromCorners(Vector2 corner1, Vector2 corner2)
- {
- Box2 box;
- if (corner1.X < corner2.X)
- {
- box.Left = corner1.X;
- box.Right = corner2.X;
- }
- else
- {
- box.Left = corner2.X;
- box.Right = corner1.X;
- }
-
- if (corner1.Y < corner2.Y)
- {
- box.Top = corner1.Y;
- box.Bottom = corner2.Y;
- }
- else
- {
- box.Top = corner2.Y;
- box.Bottom = corner1.Y;
- }
-
- return box;
- }
-
///
/// Gets a float describing the width of the Box2 structure.
///
@@ -144,13 +110,32 @@ namespace OpenTK
public float Height { get { return (float)System.Math.Abs(Bottom - Top); } }
///
- /// Returns whether the box contains the specified point.
+ /// Returns whether the box contains the specified point on the closed region described by this Box2.
///
/// The point to query.
/// Whether this box contains the point.
public bool Contains(Vector2 point)
{
- return (point.X >= Left != point.X > Right) && (point.Y >= Top != point.Y > Bottom);
+ return Contains(point, true);
+ }
+
+ ///
+ /// Returns whether the box contains the specified point.
+ ///
+ /// The point to query.
+ /// Whether to include the box boundary in the test region.
+ /// Whether this box contains the point.
+ public bool Contains(Vector2 point, bool closedRegion)
+ {
+ bool xOK = (closedRegion == Left <= Right) ?
+ (point.X >= Left != point.X > Right) :
+ (point.X > Left != point.X >= Right);
+
+ bool yOK = (closedRegion == Top <= Bottom) ?
+ (point.Y >= Top != point.Y > Bottom) :
+ (point.Y > Top != point.Y >= Bottom);
+
+ return xOK && yOK;
}
///
diff --git a/Source/OpenTK/Math/Box2d.cs b/Source/OpenTK/Math/Box2d.cs
index 5fa6059c..c1f50818 100644
--- a/Source/OpenTK/Math/Box2d.cs
+++ b/Source/OpenTK/Math/Box2d.cs
@@ -99,40 +99,6 @@ namespace OpenTK
return FromDimensions(position.X, position.Y, size.X, size.Y);
}
- ///
- /// Creates a new Box2d from the specified corners.
- ///
- /// One of the corners of the box.
- /// The opposite corner of the box.
- ///
- public static Box2d FromCorners(Vector2d corner1, Vector2d corner2)
- {
- Box2d box;
- if (corner1.X < corner2.X)
- {
- box.Left = corner1.X;
- box.Right = corner2.X;
- }
- else
- {
- box.Left = corner2.X;
- box.Right = corner1.X;
- }
-
- if (corner1.Y < corner2.Y)
- {
- box.Top = corner1.Y;
- box.Bottom = corner2.Y;
- }
- else
- {
- box.Top = corner2.Y;
- box.Bottom = corner1.Y;
- }
-
- return box;
- }
-
///
/// Gets a double describing the width of the Box2d structure.
///
@@ -144,13 +110,32 @@ namespace OpenTK
public double Height { get { return (double)System.Math.Abs(Bottom - Top); } }
///
- /// Returns whether the box contains the specified point.
+ /// Returns whether the box contains the specified point on the closed region described by this Box2.
///
/// The point to query.
/// Whether this box contains the point.
public bool Contains(Vector2d point)
{
- return (point.X >= Left != point.X > Right) && (point.Y >= Top != point.Y > Bottom);
+ return Contains(point, true);
+ }
+
+ ///
+ /// Returns whether the box contains the specified point.
+ ///
+ /// The point to query.
+ /// Whether to include the box boundary in the test region.
+ /// Whether this box contains the point.
+ public bool Contains(Vector2d point, bool closedRegion)
+ {
+ bool xOK = (closedRegion == Left <= Right) ?
+ (point.X >= Left != point.X > Right) :
+ (point.X > Left != point.X >= Right);
+
+ bool yOK = (closedRegion == Top <= Bottom) ?
+ (point.Y >= Top != point.Y > Bottom) :
+ (point.Y > Top != point.Y >= Bottom);
+
+ return xOK && yOK;
}
///
diff --git a/Source/OpenTK/OpenTK.csproj b/Source/OpenTK/OpenTK.csproj
index e5f7937a..d15987e7 100644
--- a/Source/OpenTK/OpenTK.csproj
+++ b/Source/OpenTK/OpenTK.csproj
@@ -162,6 +162,7 @@
Properties\GlobalAssemblyInfo.cs
+
Code
@@ -894,8 +895,5 @@
-
-
-
-
+
\ No newline at end of file