1
$\begingroup$

I have seen this trivial example for circles

n = 5;
r = 0.2;
Table[pt[i] = RandomReal[{-1, 1}, 2], {i, 1, n}];
Graphics[{Table[Circle[pt[i], r], {i, n}]}, Axes -> True, 
 PlotRange -> {{-1, 1}, {-1, 1}}]

I would like to draw Random 3D plot of Cylinders with fix height and radius. Best Regards Danny

$\endgroup$

marked as duplicate by ubpdqn, Alexey Popkov, gpap, m_goldberg, MarcoB Apr 26 '16 at 12:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
$\begingroup$

It may be marked as a duplicate, but the answer to that post is more complicated because of the constraint that the cylinders do not intersect. For this question, just create one cylinder with the right length and radius and rotate and translate it randomly,

radius = .3;
length = 5;
cyl = Cylinder[{{0, 0, 0}, {0, 0, length}}, radius];
cylinder := 
 cyl // Rotate[#, RandomReal[{0, 2 π}], RandomReal[1, 3]] & // 
  Translate[#, RandomReal[{-5, 5}, 3]] &

Graphics3D@Table[cylinder, {50}]

Mathematica graphics

$\endgroup$
1
$\begingroup$
n = 5; r = 0.2; pt = RandomReal[{-1, 1}, {n, 2}]
Graphics3D[Cylinder[{{#[[1]], #[[2]], 0}, {#[[1]], #[[2]], 1}}, r] & /@ pt]

If you want more

n = 5; r = 0.2;
pt1 = RandomReal[{-1, 1}, {n, 3}];
pt2 = RandomReal[{-1, 1}, {n, 3}];
Graphics3D[Cylinder[{pt1[[#]], pt2[[#]]}, r] & /@ Range[n]]

enter image description here

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.