[Mathematica] Plotting a straight line in a 3D plot

1. Sep 6, 2007

euthymos

Is there any way, in Mathematica, I can plot a straight line in a 3D plot environment?

For example: Plot3D[{{y = 1 - x, z = y - 1}}, {x, -5, 5}, {y, -5, 5}]

plots two surfaces, not their intersection (which is a straight line).

Thank you in advance.

2. Sep 6, 2007

genneth

You have to use mathematica to find the intersection before you can plot it.

3. Sep 6, 2007

euthymos

how? The intersection of that two surfaces is a straight line. There's nothing to find.

4. Sep 6, 2007

AiRAVATA

Mathematica assumes you are asking it to plot two surfaces, namely y = 1 - x and z = y - 1. You should read the help file, wich comes with a lot of examples. I suggest you to use a parametric plot instead.

5. Sep 6, 2007

genneth

It's obvious to you... but not to computer. After all, the equations could be degenerate, and probably other implicit assumptions that we're used to. In this case, ParametricPlot3D is your friend -- it will give you a line in 3D. However, you'll still have to find a parametric form of the line. I'm not sure how to do that in a nice way, such that there are no edge cases, for any 2 given planes.

6. Sep 6, 2007

HallsofIvy

Staff Emeritus
The intersection of the two planes y= 1- x and z= y-1 can be written with x= 1- y and z= y-1: taking y itself as parameter, x= 1-t, y= t, z= t-1. That's what there is to find.

7. Sep 6, 2007

euthymos

Finally! I've converted the cartesian equations into parametric one and plotted with ParametricPlot3D.

ParametricPlot3D[{x = 1 - t, y = t, z = t - 1}, {t, -5, 5}]

Thanks a lot for you help! Thanks all!

8. Jul 22, 2010

mishi003

hello,
I am need to solve for a program that would give the equation of a line with one pt(x,y,z) and makes angle p to x axis and q to y axis. I have written a program that is too long, Is there an easy way to do the same?