1
$\begingroup$

I have this code which first is supposed to make random points, draw lines through the points and then make these lines radical axes of cylinders. I have two problems with my code. First, it only draws the upper half of cylinders. Second, the perspectives are really messed up, somehow twisted and uneven. For example, Show[a, ViewPoint -> Front, ImageSize -> Large, Boxed -> False] should be looking from a perspective where xy-plane is completely straight (perpendicular to z axis) but thats not what is happening. Here is my code:

plane = InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}];
     pts = RandomPoint[plane, 20, {{-10, 10}, {-10, 10}, {0, 0}}];
     a = Graphics3D[{plane, 
        Cylinder[{#, # + {#[[2]], -#[[1]], 
              4 Sqrt[3] Sqrt[#[[1]]^2 + #[[2]]^2] + 7}}, 1/2] & /@ pts, 
        Red, InfiniteLine[#, {#[[2]], -#[[1]], 
            4 Sqrt[3] Sqrt[#[[1]]^2 + #[[2]]^2] + 7}] & /@ pts, Black, 
        Sphere[{0, 0, 0}, 0.3], Blue, Sphere[pts, .1]}, 
        PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}]
     Show[a, ImageSize -> Large, Boxed -> False]
     Show[a, ViewPoint -> Above, ImageSize -> Large, Boxed -> False]
     Show[a, ViewPoint -> Front, ImageSize -> Large, Boxed -> False]
     Show[a, ViewPoint -> {0, 0, \[Infinity]}, ImageSize -> Large, 
      Boxed -> False]
     Show[a, ViewPoint -> {0, -\[Infinity], 0}, ImageSize -> Large, 
      Boxed -> False]

Any help would be appreciated. Thank you!

$\endgroup$
4
  • $\begingroup$ use Cylinder[{# - {#[[2]], -#[[1]], 4 Sqrt[3] Sqrt[#[[1]]^2 + #[[2]]^2] + 7}, # + {#[[2]], -#[[1]], 4 Sqrt[3] Sqrt[#[[1]]^2 + #[[2]]^2] + 7}}, 1/2] & /@ pts to have the cylinders extend below plane. $\endgroup$
    – kglr
    Mar 6, 2019 at 0:44
  • $\begingroup$ @kglr that worked! What is the meaning behind $#-$ and $#+$ I did this by imitating someone else's code. Could you point me to a reference? That does not fix the perspective problem though, any ideas? $\endgroup$
    – Sorfosh
    Mar 6, 2019 at 0:48
  • $\begingroup$ Sorfosh, look up Function and Slot in the docs. $\endgroup$
    – kglr
    Mar 6, 2019 at 1:24
  • $\begingroup$ Solved! I just had to reset Mathematica and kglr helped with the main issue. This can be closed or @kglr add your comment as a response $\endgroup$
    – Sorfosh
    Mar 6, 2019 at 3:57

1 Answer 1

2
$\begingroup$

Use

Cylinder[{# - {#[[2]], -#[[1]], 4 Sqrt[3] Sqrt[#[[1]]^2 + #[[2]]^2] + 7},
  # + {#[[2]], -#[[1]], 4 Sqrt[3] Sqrt[#[[1]]^2 + #[[2]]^2] + 7}}, 1/2] & /@ pts

in Graphics3D that poduces a to have the cylinders extend below plane.

Show[a, ViewPoint -> Front, ImageSize -> Large, Boxed -> False]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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