Two questions about plotting multiple lines

6 ビュー (過去 30 日間)
Alasdair McAndrew
Alasdair McAndrew 2016 年 10 月 30 日
コメント済み: Alasdair McAndrew 2016 年 10 月 30 日
I'm trying to plot a ruled surface: that is, a surface composed of a lot of straight lines (in 3d). Now, given end points (x1,y1,z1) and (x2,y2,z2) of a line, the command for plotting it is
line([x1,x2],[y1,y2],[z1,z2])
In my case I have 60 such lines, and matrices holding all the x, y and z values. So here are my questions:
  1. How can I draw multiple lines, other than using a "for" loop? Is there a version of the "line" command above where the inputs can be arrays of coordinate values?
  2. Is there a hidden line algorithm for such a plot? I know you can show or hide lines in surfaces, but can it be done with multiple straight lines in 3D?
Thank you!

採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 30 日
line() can only be used for one line at a time.
plot() creates one line for each column of Y values.
Hidden lines only make sense if one line is directly behind another from the perspective of the viewer, which would depend upon the angle that you had turned the view, either with the tool or with the view() command.
When you have a 3 dimensional graph, then by default what is "further away" from the viewpoint is what is hidden. If you happen to be looking directly down the Z axes then that means that the locations with greater Z would be on top and if there was a location with the same X and Y but lower Z then it would be hidden.
Hidden surfaces generally have more use than hidden lines as they block off large areas from view, not just exact correspondance from one particular viewpoint.
  1 件のコメント
Alasdair McAndrew
Alasdair McAndrew 2016 年 10 月 30 日
Many thanks - as usual, you are a fount of excellent information! I didn't think hidden lines were possible, but, well, you never know what's possible. I'll check out plot() for sets of lines.
In fact using a for loop worked very well, and gave a very nice result - even better when I color coded the lines.

サインインしてコメントする。

その他の回答 (0 件)

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by