Distance Between Two Lines in 3D
Find the shortest distance between two lines in 3D space from each line point and direction vector. Detects skew, parallel and intersecting cases and shows closest points.
Input
Enter a point and a direction vector for each of two lines in 3D space to compute the shortest distance between them. The skew, parallel or intersecting relationship and the closest points are also shown.
Line 1 point P1
Coordinates of a point the line passes through.
Line 1 direction d1
Vector giving the line direction. The zero vector is not allowed.
Line 2 point P2
Coordinates of a point the line passes through.
Line 2 direction d2
Vector giving the line direction. The zero vector is not allowed.
Result
Shortest distance between the lines
1
Relationship
Skew
Cross product magnitude
1
Closest point on line 1
(0, 0, 0)
Closest point on line 2
(0, 1, 0)
Using the cross product n = d1 x d2, the distance is the absolute value of w · n over the magnitude of n for skew or intersecting lines, and the magnitude of w x d1 over the magnitude of d1 for parallel lines, where w = P1 - P2.
How it works
- Each line is given by a point P and a direction vector d. Line 1 uses P1 and d1, line 2 uses P2 and d2.
- Compute the cross product n = d1 x d2 of the direction vectors. If the magnitude of n is nonzero the lines are skew or intersecting.
- For skew or intersecting lines the distance is the absolute value of w · n divided by the magnitude of n, where w = P1 - P2.
- When the cross product n is zero the lines are parallel. The distance is then the distance from point P2 to line 1, equal to the magnitude of w x d1 divided by the magnitude of d1.
- Parallel lines with distance 0 are the same line. For skew or intersecting lines the closest point on each line is also shown.
Reviews
Tell us what you think of this calculator.
Write a review
- Home
Distance Between Two Lines in 3D