#point_query(point : Vect, max_distance : Number = 0, filter : ShapeFilter = ShapeFilter::ALL) : Array(PointQueryInfo)#
Query the space at a point for shapes within the given distance range.
The filter is applied to the query and follows the same rules as the collision detection. Sensor shapes are included. If a max_distance of 0 is used, the point must lie inside a shape. Negative max_distance is also allowed meaning that the point must be a under a certain depth within a shape to be considered a match.
#segment_query(start : Vect, end end_ : Vect, radius : Number = 0, filter : ShapeFilter = ShapeFilter::ALL) : Array(SegmentQueryInfo)#
Perform a directed line segment query (like a raycast) against the space and yield each shape intersected.
The filter is applied to the query and follows the same rules as the collision detection. Sensor shapes are included.
Query a space for any shapes overlapping the given shape and yield each shape found.
#point_query(p : Vect) : PointQueryInfo#
Perform a nearest point query. It finds the closest point on the surface of shape to a specific point.
#segment_query(a : Vect, b : Vect, radius : Number = 0) : SegmentQueryInfo?#
Perform a segment query against a shape: check if the line segment from start to end intersects the shape.
#distance : Float64#
The distance to the point (negative if the point is inside the shape).
#gradient : Vect#
The gradient of the signed distance function.
The value should be similar to
point/distance, but accurate even for very small values of
Segment queries return more information than just a simple yes or no, they also return where a shape was hit and its surface normal at the hit point. This object holds that information.
Segment queries are like ray casting, but because not all spatial indexes allow processing infinitely long ray queries it is limited to segments. In practice this is still very fast and you don't need to worry too much about the performance as long as you aren't using extremely long segments for your queries.