C# Class FarseerPhysics.Common.LineTools

Collection of helper methods for misc collisions. Does float tolerance and line collisions with lines and AABBs.
ファイルを表示 Open project: prime31/Nez Class Usage Examples

Public Methods

Method Description
distanceBetweenPointAndLineSegment ( Vector2 &point, Vector2 &start, Vector2 &end ) : 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 ) : Vertices

Get all intersections between a line segment and an AABB.

lineSegmentVerticesIntersect ( Vector2 &point1, Vector2 &point2, Vertices vertices ) : 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)

Method Details

distanceBetweenPointAndLineSegment() public static method

public static distanceBetweenPointAndLineSegment ( Vector2 &point, Vector2 &start, Vector2 &end ) : float
point Vector2
start Vector2
end Vector2
return float

lineIntersect() public static method

public static lineIntersect ( Vector2 p1, Vector2 p2, Vector2 q1, Vector2 q2 ) : Vector2
p1 Vector2
p2 Vector2
q1 Vector2
q2 Vector2
return Vector2

lineIntersect() public static method

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.
return bool

lineIntersect() public static method

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.
return bool

lineIntersect2() public static method

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
return bool

lineSegmentAABBIntersect() public static method

Get all intersections between a line segment and an AABB.
public static lineSegmentAABBIntersect ( Vector2 &point1, Vector2 &point2, AABB aabb ) : Vertices
point1 Vector2 The first point of the line segment to test
point2 Vector2 The second point of the line segment to test.
aabb FarseerPhysics.Collision.AABB The AABB that is used for testing intersection.
return Vertices

lineSegmentVerticesIntersect() public static method

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 ) : Vertices
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
return Vertices