pointSegmentDistance

pyvsim.Utils.pointSegmentDistance(p1, p2, x)[source]

Given one point and some line segments, calculates the euclidean distance between each segment and this point.

If the point lies outside segment, returns the distance between point and nearest extremity of the segment

Parameters :

p1 : numpy.ndarray \((N,3)\)

Coordinates of segments’ initial points

p2 : numpy.ndarray \((N,3)\)

Coordinates of segments’ final points

x : numpy.array(3)

Coordinates of point

Returns :

distance : numpy.ndarray \((N)\)

Distance between each of the segments and the point

Examples

>>> p1 = np.array([[  0,  0, 0],
...                [  0,  0, 0],
...                [  0,  0, 0]])
>>> p2 = np.array([[  1,  0, 0],
...                [  0,  1, 0],
...                [  0,  0, 1]])  
>>> x  = np.array([  1,  1, 1])
>>> pointSegmentDistance(p1, p2, x)
array([ 1.41421356,  1.41421356,  1.41421356])
>>> x  = np.array([  2,  0, 0])
>>> pointSegmentDistance(p1, p2, x)
array([ 1.,  2.,  2.])

This Page