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

Line plot 3d

  1. May 27, 2009 #1
    Hey.

    Is it possible to plot a line in 3D from one point to another?
    The source of the points is a list.
     
  2. jcsd
  3. May 27, 2009 #2

    Dale

    Staff: Mentor

    Yes.
     
  4. May 27, 2009 #3

    Hepth

    User Avatar
    Gold Member

    List1 = {{1, 1, 1}, {3, 4, 5}};
    List2 = {{-3, 1, 2}, {2, 1, 5}};
    L3 = {Line[List1], Line[List2]}
    Graphics3D[L3, Axes -> True,
    PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}]
     
  5. May 28, 2009 #4
    Thank you.

    I have a long list with points from an external file. How can i do this?
    {{3,6,5},{2,4,1},{3,5,4},{6,7,4},{3,2,1},{1,1,1},...}

    Every 2nd point should be the end-point of the line.
    Or is it better to make it like this?
    {{3,6,5,2,4,1},{3,5,4,6,7,4},{3,2,1,1,1,1},...}
     
    Last edited: May 28, 2009
  6. May 28, 2009 #5

    Dale

    Staff: Mentor

    If your long list of points is in a variable called dat (i.e. dat={{3,6,5},{2,4,1},{3,5,4},{6,7,4},{3,2,1},{1,1,1}}) then

    Graphics3D[Line[Partition[dat,2]]]

    will plot the lines
     
  7. May 29, 2009 #6
    great support in this forums.

    Thanks a lot DaleSpam.


    greets
    button
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook