Plot multiple line segments on a 2D plot in Mathematica

I would like to build several, maybe thousands of line segments on one 2D graphic in Mathematica. These line segments will be determined by an algorithm that will detect and store the endpoints of each segment. Once the algorithm has identified all line segments in the final 2D domain and range (for example, x = 0.4 and y = 0.05), I would like to build them in one section. Thanks for any suggestions.

+4
source share
1 answer

Something like that?

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 *) 

alt text

NTN!

Edit

Repeating your question, I'm not sure if you are generating a continuous line by defining one endpoint at a time or a set of unconnected segments (as indicated above). Just in case, you go 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 ] 

alt text

+5
source

Source: https://habr.com/ru/post/1334866/


All Articles