C# Class Project290.Physics.Common.LineTools

Collection of helper methods for misc collisions. Does float tolerance and line collisions with lines and AABBs.
Afficher le fichier Open project: scastle/Solitude Class Usage Examples

Méthodes publiques

Méthode Description
DistanceBetweenPointAndLineSegment ( Vector2 &point, Vector2 &lineEndPoint1, Vector2 &lineEndPoint2 ) : float
DistanceBetweenPointAndPoint ( Vector2 &point1, Vector2 &point2 ) : float
LineIntersect ( Vector2 p1, Vector2 p2, Vector2 q1, Vector2 q2 ) : Vector2
LineIntersect ( Vector2 &point1, Vector2 &point2, Vector2 &point3, Vector2 &point4, Vector2 &intersectionPoint ) : bool

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).

LineIntersect ( Vector2 &point1, Vector2 &point2, Vector2 &point3, Vector2 &point4, bool firstIsSegment, bool secondIsSegment, Vector2 &point ) : bool

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

LineIntersect2 ( Vector2 a0, Vector2 a1, Vector2 b0, Vector2 b1, Vector2 &intersectionPoint ) : bool

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.

LineSegmentAABBIntersect ( Vector2 &point1, Vector2 &point2, AABB aabb, List &intersectionPoints ) : void

Get all intersections between a line segment and an AABB.

LineSegmentVerticesIntersect ( Vector2 &point1, Vector2 &point2, Vertices vertices, List &intersectionPoints ) : void

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)

Method Details

DistanceBetweenPointAndLineSegment() public static méthode

public static DistanceBetweenPointAndLineSegment ( Vector2 &point, Vector2 &lineEndPoint1, Vector2 &lineEndPoint2 ) : float
point Vector2
lineEndPoint1 Vector2
lineEndPoint2 Vector2
Résultat float

DistanceBetweenPointAndPoint() public static méthode

public static DistanceBetweenPointAndPoint ( Vector2 &point1, Vector2 &point2 ) : float
point1 Vector2
point2 Vector2
Résultat float

LineIntersect() public static méthode

public static LineIntersect ( Vector2 p1, Vector2 p2, Vector2 q1, Vector2 q2 ) : Vector2
p1 Vector2
p2 Vector2
q1 Vector2
q2 Vector2
Résultat Vector2

LineIntersect() public static méthode

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 LineIntersect ( Vector2 &point1, Vector2 &point2, Vector2 &point3, Vector2 &point4, Vector2 &intersectionPoint ) : bool
point1 Vector2 The first point of the first line segment.
point2 Vector2 The second point of the first line segment.
point3 Vector2 The first point of the second line segment.
point4 Vector2 The second point of the second line segment.
intersectionPoint Vector2 This is set to the intersection /// point if an intersection is detected.
Résultat bool

LineIntersect() public static méthode

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 LineIntersect ( Vector2 &point1, Vector2 &point2, Vector2 &point3, Vector2 &point4, bool firstIsSegment, bool secondIsSegment, Vector2 &point ) : bool
point1 Vector2 The first point of the first line segment.
point2 Vector2 The second point of the first line segment.
point3 Vector2 The first point of the second line segment.
point4 Vector2 The second point of the second line segment.
firstIsSegment bool Set this to true to require that the /// intersection point be on the first line segment.
secondIsSegment bool Set this to true to require that the /// intersection point be on the second line segment.
point Vector2 This is set to the intersection /// point if an intersection is detected.
Résultat bool

LineIntersect2() public static méthode

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 LineIntersect2 ( Vector2 a0, Vector2 a1, Vector2 b0, Vector2 b1, Vector2 &intersectionPoint ) : bool
a0 Vector2
a1 Vector2
b0 Vector2
b1 Vector2
intersectionPoint Vector2
Résultat bool

LineSegmentAABBIntersect() public static méthode

Get all intersections between a line segment and an AABB.
public static LineSegmentAABBIntersect ( Vector2 &point1, Vector2 &point2, AABB aabb, List &intersectionPoints ) : void
point1 Vector2 The first point of the line segment to test
point2 Vector2 The second point of the line segment to test.
aabb Project290.Physics.Collision.AABB The AABB that is used for testing intersection.
intersectionPoints List An list of intersection points. Any intersection points found will be added to this list.
Résultat void

LineSegmentVerticesIntersect() public static méthode

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 LineSegmentVerticesIntersect ( Vector2 &point1, Vector2 &point2, Vertices vertices, List &intersectionPoints ) : void
point1 Vector2 The first point of the line segment to test
point2 Vector2 The second point of the line segment to test.
vertices Vertices The vertices, as described above
intersectionPoints List An list of intersection points. Any intersection points /// found will be added to this list.
Résultat void