Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Sep 6, 2007 #1
    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. jcsd
  3. Sep 6, 2007 #2
    You have to use mathematica to find the intersection before you can plot it.
  4. Sep 6, 2007 #3
    how? The intersection of that two surfaces is a straight line. There's nothing to find.
  5. Sep 6, 2007 #4
    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.
  6. Sep 6, 2007 #5
    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.
  7. Sep 6, 2007 #6


    User Avatar
    Science Advisor

    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.
  8. Sep 6, 2007 #7
    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!
  9. Jul 22, 2010 #8
    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?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook