1
$\begingroup$

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.

$\endgroup$
  • 3
    $\begingroup$ Use ParametricPlot3D[] with the usual vector equation (1 - t) pt1 + t pt2. Alternatively, look up Line[] or InfiniteLine[]. $\endgroup$ – J. M. will be back soon Apr 9 '16 at 11:17
  • $\begingroup$ 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. $\endgroup$ – Gelios Apr 9 '16 at 12:09
  • $\begingroup$ Plot3D[] produces surfaces, and a line is not a surface. $\endgroup$ – J. M. will be back soon Apr 9 '16 at 13:39
  • 1
    $\begingroup$ Another alternative is to use on the the graphics commands:, for instance, Graphics3D[Line[{{2, -2, 0}, {1, -3, -5}}]] $\endgroup$ – bill s Apr 9 '16 at 13:57
1
$\begingroup$

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:

Graphics3D
Line

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.