It is possible to perform a point distance query by calling the function FC_PointDistanceQuery The function expects one Cartesian 3D point and object implementing the interface COD.IF_CollisionQueryInterface.
Collision objects, groups and entities are valid implementations of the IF_CollisionQueryInterface, meaning that you may provide any of them as input for the function.
There is a third input called i_xEvaluateClosestPoint that, if set to TRUE, forces the function to evaluate the closest point on the IF_CollisionQueryInterface input.
The following list of minimum steps is required to perform a point distance query:
Step |
Action |
---|---|
1 |
Define a collision object, group or entity and make sure it has xConfigured = TRUE in the case of an object, or xUpdated = TRUE in the case of a group or an entity. |
2 |
Provide the 3D point and the IF_CollisionQueryInterface implementation as inputs of the FC_PointDistanceQuery function. |
On a successful call of FC_PointDistanceQuery, the function returns information about the distance between the point and the IF_CollisionQueryInterface implementation.
Example of point distance query:
The following is an example in the case of a collision object:
//configure the object that is an OBB
fbOBB.SetCenterHalfExtentsOrientation(
i_stCenter := stOBBCenter,
i_stHalfExtents := stOBBHalfExtents,
i_stOrientation := stOBBOrientation,
q_xError=> xError,
q_etResult=> etResult,
q_sResultMsg=> sResultMsg
);
//check diagnostics here
IF xError THEN
//do something to handle the error
…
END_IF
//now that the OBB object is configured, it is possible to
//perform a point distance query
COD.FC_PointDistanceQuery(
i_stPoint:= stPoint,
i_ifQueryInterface:= fbOBB,
i_xEvaluateClosestPoint:= FALSE,
q_xError=> xError,
q_etResult=> etResult,
q_sResultMsg=> sResultMsg,
q_xIsPointInside=> xIsPointInside,
q_lrDistance=> lrDistance,
q_stClosestPoint=> stClosestPoint
);