# Plot a line passing through two given points in 3D space

How can I plot straight line passing through two given points in 3D coordinates?

For example, given the points M1: (2, -2, 0) and M2: (1, -3, -5)

(x-2)/(1-2)  == (y+2) / (-2+3) == (z-0) / -5
(x-2)/-1 == (y+2)/1 == z/-5


I did some attempts with Solve and Reduce, but they didnt give the results I expected.

• Use ParametricPlot3D[] with the usual vector equation (1 - t) pt1 + t pt2. Alternatively, look up Line[] or InfiniteLine[]. – J. M. will be back soon Apr 9 '16 at 11:17
• Thanks. I have one question more... is there are some possibilities to obtain this result in just Plot3D, not in the Parametric ? i used y /. Solve[(x - vec2[[1]])/vec[[1]] == (y - vec2[[2]])/vec[[2]], y] to obtain same result in 2d plots. – Gelios Apr 9 '16 at 12:09
• Plot3D[] produces surfaces, and a line is not a surface. – J. M. will be back soon Apr 9 '16 at 13:39
• Another alternative is to use on the the graphics commands:, for instance, Graphics3D[Line[{{2, -2, 0}, {1, -3, -5}}]] – bill s Apr 9 '16 at 13:57

Example:

Arbitrary data

p1 = {0, 0, 0}  (* This defines point no. 1*)
p2 = {0, 0, 10} (* This defines point no. 2*)


Process

Graphics3D[Line[{p1, p2}]]


Reference: