Class LineTools
- Namespace
- Alis.Core.Physic.Common
- Assembly
- Alis.dll
Collection of helper methods for misc collisions. Does float tolerance and line collisions with lines and AABBs.
public static class LineToolsInheritance
Inherited Members
Methods
DistanceBetweenPointAndLineSegment(ref Vector2, ref Vector2, ref Vector2)
Distances the between point and line segment using the specified point
public static float DistanceBetweenPointAndLineSegment(ref Vector2 point, ref Vector2 start, ref Vector2 end)Parameters
Returns
- float
-
The float
LineIntersect(Vector2, Vector2, Vector2, Vector2)
Lines the intersect using the specified p 1
public static Vector2 LineIntersect(Vector2 p1, Vector2 p2, Vector2 q1, Vector2 q2)Parameters
Returns
- Vector2
-
The
LineIntersect(ref Vector2, ref Vector2, ref Vector2, ref Vector2, bool, bool, out Vector2)
This method detects if two line segments (or lines) intersect,
and, if so, the point of intersection. Use the firstIsSegment and
secondIsSegment parameters to set whether the intersection point
must be on the first and second line segments. Setting these
both to true means you are doing a line-segment to line-segment
intersection. Setting one of them to true means you are doing a
line to line-segment intersection test, and so on.
Note: If two line segments are coincident, then
no intersection is detected (there are actually
infinite intersection points).
Author: Jeremy Bell
public static bool LineIntersect(ref Vector2 point1, ref Vector2 point2, ref Vector2 point3, ref Vector2 point4, bool firstIsSegment, bool secondIsSegment, out Vector2 point)Parameters
point1Vector2-
The first point of the first line segment.
point2Vector2-
The second point of the first line segment.
point3Vector2-
The first point of the second line segment.
point4Vector2-
The second point of the second line segment.
firstIsSegmentbool-
Set this to true to require that the intersection point be on the first line segment.
secondIsSegmentbool-
Set this to true to require that the intersection point be on the second line segment.
pointVector2-
This is set to the intersection point if an intersection is detected.
Returns
- bool
-
True if an intersection is detected, false otherwise.
LineIntersect(Vector2, Vector2, Vector2, Vector2, bool, bool, out Vector2)
This method detects if two line segments (or lines) intersect,
and, if so, the point of intersection. Use the firstIsSegment and
secondIsSegment parameters to set whether the intersection point
must be on the first and second line segments. Setting these
both to true means you are doing a line-segment to line-segment
intersection. Setting one of them to true means you are doing a
line to line-segment intersection test, and so on.
Note: If two line segments are coincident, then
no intersection is detected (there are actually
infinite intersection points).
Author: Jeremy Bell
public static bool LineIntersect(Vector2 point1, Vector2 point2, Vector2 point3, Vector2 point4, bool firstIsSegment, bool secondIsSegment, out Vector2 intersectionPoint)Parameters
point1Vector2-
The first point of the first line segment.
point2Vector2-
The second point of the first line segment.
point3Vector2-
The first point of the second line segment.
point4Vector2-
The second point of the second line segment.
firstIsSegmentbool-
Set this to true to require that the intersection point be on the first line segment.
secondIsSegmentbool-
Set this to true to require that the intersection point be on the second line segment.
intersectionPointVector2-
This is set to the intersection point if an intersection is detected.
Returns
- bool
-
True if an intersection is detected, false otherwise.
LineIntersect(ref Vector2, ref Vector2, ref Vector2, ref Vector2, out Vector2)
This method detects if two line segments intersect, and, if so, the point of intersection. Note: If two line segments are coincident, then no intersection is detected (there are actually infinite intersection points).
public static bool LineIntersect(ref Vector2 point1, ref Vector2 point2, ref Vector2 point3, ref Vector2 point4, out Vector2 intersectionPoint)Parameters
point1Vector2-
The first point of the first line segment.
point2Vector2-
The second point of the first line segment.
point3Vector2-
The first point of the second line segment.
point4Vector2-
The second point of the second line segment.
intersectionPointVector2-
This is set to the intersection point if an intersection is detected.
Returns
- bool
-
True if an intersection is detected, false otherwise.
LineIntersect(Vector2, Vector2, Vector2, Vector2, out Vector2)
This method detects if two line segments intersect, and, if so, the point of intersection. Note: If two line segments are coincident, then no intersection is detected (there are actually infinite intersection points).
public static bool LineIntersect(Vector2 point1, Vector2 point2, Vector2 point3, Vector2 point4, out Vector2 intersectionPoint)Parameters
point1Vector2-
The first point of the first line segment.
point2Vector2-
The second point of the first line segment.
point3Vector2-
The first point of the second line segment.
point4Vector2-
The second point of the second line segment.
intersectionPointVector2-
This is set to the intersection point if an intersection is detected.
Returns
- bool
-
True if an intersection is detected, false otherwise.
LineIntersect2(ref Vector2, ref Vector2, ref Vector2, ref Vector2, out Vector2)
Check if the lines a0->a1 and b0->b1 cross. If they do, intersectionPoint will be filled with the point of crossing. Grazing lines should not return true.
public static bool LineIntersect2(ref Vector2 a0, ref Vector2 a1, ref Vector2 b0, ref Vector2 b1, out Vector2 intersectionPoint)Parameters
Returns
LineSegmentAabbIntersect(ref Vector2, ref Vector2, AABB)
Get all intersections between a line segment and an AABB.
public static Vertices LineSegmentAabbIntersect(ref Vector2 point1, ref Vector2 point2, AABB aabb)Parameters
point1Vector2-
The first point of the line segment to test
point2Vector2-
The second point of the line segment to test.
aabbAABB-
The AABB that is used for testing intersection.
Returns
LineSegmentVerticesIntersect(ref Vector2, ref Vector2, Vertices)
Get all intersections between a line segment and a list of vertices representing a polygon. The vertices reuse adjacent points, so for example edges one and two are between the first and second vertices and between the second and third vertices. The last edge is between vertex vertices.Count - 1 and verts0. (ie, vertices from a Geometry or AABB)
public static Vertices LineSegmentVerticesIntersect(ref Vector2 point1, ref Vector2 point2, Vertices vertices)Parameters
point1Vector2-
The first point of the line segment to test
point2Vector2-
The second point of the line segment to test.
verticesVertices-
The vertices, as described above