19.12.2 segmentQuery

info = physics.Shape:segmentQuery(vecta, vectb)

Parameter

Type

Description

self

in physics.Shape

The input Shape

vecta

in physics.Vect

One end point of the segment

vectb

in physics.Vect

The other end point of the segment

info

out physics.SegmentQueryInfo

Information about where the segment and Shape intersect. Nil if no intersection

Checks if the line segment from vecta to vectb intersects the Shape. Returns a
SegmentQueryInfo object with the result of the query or nil if no intersection.

If a segment query starts inside of a shape then the result is somewhat undefined. Circles and polygons will not report a collision with that shape, and segments will report an incorrect point and normal if they do detect a collision with that shape. To get around this deficiency, use a separate point query to determine if the segment query starts inside of a shape.

See the SegmentQueryInfo methods below for helper routines to convert the results to world coordinates or absolute distance.

Introduced in platform.apiLevel = '2.0'