Struct Quadrangle
- Namespace
- OmegaEngine.Foundation.Geometry
- Assembly
- OmegaEngine.Foundation.dll
A 2D polygon consisting of four points.
[TypeConverter(typeof(QuadrangleConverter))]
public struct Quadrangle : IEquatable<Quadrangle>
- Implements
- Inherited Members
- Extension Methods
Constructors
Quadrangle(Vector2, Vector2, Vector2, Vector2)
Creates a new quadrangle. Counter-clockwise ordering is recommended.
public Quadrangle(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4)
Parameters
p1
Vector2p2
Vector2p3
Vector2p4
Vector2
Quadrangle(RectangleF)
Creates a new quadrangle from a simple rectangle.
public Quadrangle(RectangleF rectangle)
Parameters
rectangle
RectangleF
Quadrangle(float, float, float, float, float, float, float, float)
Creates a new quadrangle. Counter-clockwise ordering is recommended.
public Quadrangle(float p1X, float p1Y, float p2X, float p2Y, float p3X, float p3Y, float p4X, float p4Y)
Parameters
Properties
Edge1
public Vector2Ray Edge1 { get; }
Property Value
Edge2
public Vector2Ray Edge2 { get; }
Property Value
Edge3
public Vector2Ray Edge3 { get; }
Property Value
Edge4
public Vector2Ray Edge4 { get; }
Property Value
P1
The coordinates of the first point; counter-clockwise ordering recommended.
public readonly Vector2 P1 { get; }
Property Value
- Vector2
P2
The coordinates of the second point; counter-clockwise ordering recommended.
public readonly Vector2 P2 { get; }
Property Value
- Vector2
P3
The coordinates of the third point; counter-clockwise ordering recommended.
public readonly Vector2 P3 { get; }
Property Value
- Vector2
P4
The coordinates of the fourth point; counter-clockwise ordering recommended.
public readonly Vector2 P4 { get; }
Property Value
- Vector2
Methods
Equals(Quadrangle)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Quadrangle other)
Parameters
other
QuadrangleAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
IntersectCircle(float)
If the points are stored counter-clockwise and form a convex polygon, this will test if a circle with the origin (0;0) lies inside it.
public bool IntersectCircle(float radius)
Parameters
radius
floatThe rectangle to test for intersection.
Returns
- bool
true
if the circle lies within the quadrangle.
IntersectWith(Quadrangle)
This will test if two quadrangles intersect with each other. Only works if both quadrangles are counter-clockwise and form a convex polygon.
public bool IntersectWith(Quadrangle quadrangle)
Parameters
quadrangle
QuadrangleThe other quadrangle to test for intersection.
Returns
- bool
true
ifquadrangle
intersects with this quadrangle.
IntersectWith(Vector2)
If the points are stored counter-clockwise and form a convex polygon, this will test if a point lies inside it.
public bool IntersectWith(Vector2 point)
Parameters
point
Vector2The point to test for intersection.
Returns
- bool
true
ifpoint
lies within the quadrangle.
IntersectWith(RectangleF)
If the points are stored counter-clockwise and form a convex polygon, this will test if a rectangle lies inside it.
public bool IntersectWith(RectangleF rectangle)
Parameters
rectangle
RectangleFThe rectangle to test for intersection.
Returns
- bool
true
ifrectangle
lies within the quadrangle.
Offset(Vector2)
Returns a new Quadrangle shifted by distance
.
public Quadrangle Offset(Vector2 distance)
Parameters
distance
Vector2This value is added to each corner position.
Returns
- Quadrangle
The shifted Quadrangle.
Rotate(float)
Returns a new Quadrangle rotated by rotation
around the origin.
public Quadrangle Rotate(float rotation)
Parameters
rotation
floatThe angle to rotate by in degrees.
Returns
- Quadrangle
The rotated Quadrangle.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(Quadrangle, Quadrangle)
public static bool operator ==(Quadrangle left, Quadrangle right)
Parameters
left
Quadrangleright
Quadrangle
Returns
operator !=(Quadrangle, Quadrangle)
public static bool operator !=(Quadrangle left, Quadrangle right)
Parameters
left
Quadrangleright
Quadrangle