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

AI Thread Summary
In Mathematica, to plot a straight line in a 3D environment, one should use ParametricPlot3D instead of Plot3D, as the latter is designed for surfaces. The intersection of two planes, such as y = 1 - x and z = y - 1, can be expressed in parametric form, which allows for straightforward plotting. A suggested parametric representation is x = 1 - t, y = t, and z = t - 1, which can be plotted over a specified range for t. Additionally, there is a request for a program to derive the equation of a line given a point and angles with the axes, indicating a need for a more efficient solution.
euthymos
Messages
3
Reaction score
0
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.
 
Physics news on Phys.org
You have to use mathematica to find the intersection before you can plot it.
 
genneth said:
You have to use mathematica to find the intersection before you can plot it.

how? The intersection of that two surfaces is a straight line. There's nothing to find.
 
Mathematica assumes you are asking it to plot two surfaces, namely y = 1 - x and z = y - 1. You should read the help file, which comes with a lot of examples. I suggest you to use a parametric plot instead.
 
euthymos said:
how? The intersection of that two surfaces is a straight line. There's nothing to find.

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.
 
euthymos said:
how? The intersection of that two surfaces is a straight line. There's nothing to find.
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.
 
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!
 
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?
 

Similar threads

Back
Top