Regular API function

simCheckDistance / sim.checkDistance

Description Checks the minimum distance between two entities. The measurable flags of the entities are overridden if the entities are objects.
C synopsis simInt simCheckDistance(simInt entity1Handle,simInt entity2Handle,simFloat threshold,simFloat* distanceData)
C parameters
entity1Handle: handle of entity 1 (can be an object handle or a collection handle)
entity2Handle: handle of entity 2 (can be an object handle or a collection handle), or sim_handle_all to check entity1 against all other measurable objects
threshold: if distance is bigger than the threshold, the distance is not calculated and return value is 0. If threshold is 0 or negative, then no threshold is used.
distanceData: distanceData[0]-distanceData[5] represents the distance segment, distanceData[6] is the distance between the entities. This data is valid only if return value is 1
C return value
0 or 1 if operation was successful (1 if distance is smaller than threshold), -1 otherwise
Lua synopsis int result,table[7] distanceData,table[2] objectHandlePair=sim.checkDistance(int entity1Handle,int entity2Handle,float threshold=0)
Lua parameters
entity1Handle: handle of entity 1 (can be an object handle or a collection handle)
entity2Handle: handle of entity 2 (can be an object handle or a collection handle), or sim.handle_all to check entity1 against all other measurable objects
threshold: if distance is bigger than the threshold, the distance is not calculated and result is 0. If threshold is 0 or negative, then no threshold is used.
Lua return values
result: 0 or 1 (1 if distance is smaller than threshold)
distanceData: distanceData[1]-distanceData[6] represents the distance segment, distanceData[7] is the distance between the entities.
objectHandlePair: the handles of the two objects that hold the minimum distance segment.
Remote API equiv.
B0-based remote API: simxCheckDistance
Legacy remote API: simxCheckDistance