plot of multiple line segments on 2D plot in Mathematica
I would like to plot multiple, perhaps thousands of line segments on a single 2D plot in Mathematica. These line segments would be determined from an algorithm that would detected and save 开发者_如何学编程each segments endpoints. Once the algorithm has determined all the line segments within a finite 2D plot domain and range (e.g., x = 0,4 and y=0,0.5), I would like to plot them all on a single plot. Thanks for any suggestions.
Something like this?
detectEndPoints := {
{RandomReal[{0, 4}], RandomReal[{0, 5}]},
{RandomReal[{0, 4}], RandomReal[{0, 5}]}};
segments = Table[detectEndPoints , {1000}];
(* Graphics[Line /@ segments] Old Way *)
Graphics[Line @ segments] (* Valid since V6. Thanks @Mark McClure *)
HTH!
Edit
Re-reading your question, I am not sure whether you are generating a continuous line by determining one endpoint at a time, or a set of non-connected segments (as above). Just in case you are going the continuous way:
detectEndPointsV2[i_] := {Cos[2 Pi i 17/100], Sin[2 Pi 17 i/100]};
segments = Table[detectEndPointsV2[i], {i, 101}];
Graphics[Line@segments]
精彩评论