Use primary constructor for Rectangle
This commit is contained in:
parent
6f86e3576a
commit
d92487ffc7
@ -4,28 +4,22 @@ namespace SpatialCollections
|
|||||||
{
|
{
|
||||||
public enum IntersectionType { Contains, Intersects, Disjoint }
|
public enum IntersectionType { Contains, Intersects, Disjoint }
|
||||||
|
|
||||||
public class Rectangle
|
public class Rectangle(Vector2 min, Vector2 max)
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Vector containing the lowest X and Y coordinates contained in the rectangle.
|
/// Vector containing the lowest X and Y coordinates contained in the rectangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 Min;
|
public Vector2 Min = min;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Vector containing the highest X and Y coordinates contained in the rectangle.
|
/// Vector containing the highest X and Y coordinates contained in the rectangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 Max;
|
public Vector2 Max = max;
|
||||||
|
|
||||||
public Vector2 Center => (Max + Min) * 0.5f;
|
public Vector2 Center => (Max + Min) * 0.5f;
|
||||||
|
|
||||||
public Vector2 Size => Max - Min;
|
public Vector2 Size => Max - Min;
|
||||||
|
|
||||||
public Rectangle(Vector2 min, Vector2 max)
|
|
||||||
{
|
|
||||||
Min = min;
|
|
||||||
Max = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Contains(Vector2 position)
|
public bool Contains(Vector2 position)
|
||||||
{
|
{
|
||||||
return Min.X <= position.X && position.X <= Max.X && Min.Y <= position.Y && position.Y <= Max.Y;
|
return Min.X <= position.X && position.X <= Max.X && Min.Y <= position.Y && position.Y <= Max.Y;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user