Line2
Namespace: Murder.Core.Geometry
Assembly: Murder.dll
public sealed struct Line2
Class for a simple line with two points. This is based on a Otter2d class: https://github.com/kylepulver/Otter/blob/master/Otter/Utility/Line2.cs
⭐ Constructors
public Line2(float x1, float y1, float x2, float y2)
Create a new Line2.
Parameters
x1
float
y1
float
x2
float
y2
float
public Line2(Vector2 start, Vector2 end)
Create a new Line2.
Parameters
start
Vector2
end
Vector2
⭐ Properties
Bottom
public float Bottom { get; }
The bottom most Y position of the line.
Returns
float
End
public Vector2 End { get; }
The second point of a line as a vector2.
Returns
Vector2
Height
public float Height { get; }
Returns
float
Left
public float Left { get; }
The left most X position of the line.
Returns
float
Right
public float Right { get; }
The right most X position of the line.
Returns
float
Start
public Vector2 Start { get; }
The first point of the line as a vector2.
Returns
Vector2
Top
public float Top { get; }
The top most Y position of the line.
Returns
float
Width
public float Width { get; }
Returns
float
X1
public readonly float X1;
The X position for the first point.
Returns
float
X2
public readonly float X2;
The X position for the second point.
Returns
float
Y1
public readonly float Y1;
The Y position for the first point.
Returns
float
Y2
public readonly float Y2;
The Y position for the second point.
Returns
float
⭐ Methods
GetClosestPoint(Vector2, float, out Vector2&)
public bool GetClosestPoint(Vector2 point, float maxRange, Vector2& closest)
Parameters
point
Vector2
maxRange
float
closest
Vector2&
Returns
bool
Intersects(Line2)
public bool Intersects(Line2 other)
Intersection test on another line. (http://ideone.com/PnPJgb)
Parameters
other
Line2
Returns
bool
IntersectsCircle(Circle)
public bool IntersectsCircle(Circle circle)
Check the intersection against a circle.
Parameters
circle
Circle
Returns
bool
IntersectsRect(Rectangle)
public bool IntersectsRect(Rectangle rect)
Parameters
rect
Rectangle
Returns
bool
IntersectsRect(float, float, float, float)
public bool IntersectsRect(float x, float y, float width, float height)
Check intersection against a rectangle.
Parameters
x
float
y
float
width
float
height
float
Returns
bool
TryGetIntersectingPoint(Circle, out Vector2&)
public bool TryGetIntersectingPoint(Circle circle, Vector2& hitPoint)
Parameters
circle
Circle
hitPoint
Vector2&
Returns
bool
TryGetIntersectingPoint(Line2, Line2, out Vector2&)
public bool TryGetIntersectingPoint(Line2 line1, Line2 line2, Vector2& hitPoint)
Parameters
line1
Line2
line2
Line2
hitPoint
Vector2&
Returns
bool
TryGetIntersectingPoint(Line2, out Vector2&)
public bool TryGetIntersectingPoint(Line2 other, Vector2& hitPoint)
Parameters
other
Line2
hitPoint
Vector2&
Returns
bool
TryGetIntersectingPoint(Rectangle, out Vector2&)
public bool TryGetIntersectingPoint(Rectangle rect, Vector2& hitPoint)
Parameters
rect
Rectangle
hitPoint
Vector2&
Returns
bool
TryGetIntersectingPoint(float, float, float, float, out Vector2&)
public bool TryGetIntersectingPoint(float x, float y, float width, float height, Vector2& hitPoint)
Parameters
x
float
y
float
width
float
height
float
hitPoint
Vector2&
Returns
bool
Length()
public float Length()
Returns
float
LengthSquared()
public float LengthSquared()
Returns
float
ToString()
public virtual string ToString()
Returns
string
⚡