linesIntersection

pyvsim.Utils.linesIntersection(v, p)[source]

Calculates the intersection of a list of lines. If no intersection exists, will return a point that minimizes the square of the distances to the given lines.

Parameters :

v : numpy.ndarray \((N,M)\)

A list of vectors with the direction of the lines (for 3D vectors, M = 3)

p : numpy.ndarray \((N,M)\)

A list of vectors with a point in the line

Returns :

x : numpy.ndarray \((M)\)

The point that minimizes the square of the distance to each line

Raises :

numpy.linalg.LinAlgError :

If the given lines are almost parallel, so no unique solution can be found

Examples

>>> v = np.array([[1,0,0],
...               [0,1,0]])
>>> p = np.array([[0,0,0],
...               [0,-1,0]])
>>> linesIntersection(v,p)
array([ 0.,  0.,  0.])
>>> p = np.array([[0,0,0],[0,-1,0.1]]) # No intersection exists
>>> linesIntersection(v,p)
array([ 0.  ,  0.  ,  0.05])

This Page