# Drawing Cylindrical Segment with Graphics3D

For a visualization I need a combination of 3 Cylindrical segments to visualize the incident, reflected and refracted beam of light at a surface. I got as far as the following code.

Graphics3D[{
Polygon[{{-1.5, -1.5, 0}, {1.5, -1.5, 0}, {1.5, 1.5,0}, {-1.5, 1.5, 0}}],
Polygon[{{-1.5, 0, -1.5}, {1.5, 0, -1.5}, {1.5, 0, 1.5}, {-1.5, 0,1.5}}],
Opacity[0.5],
Cylinder[{{-1, 1, 0}, {0.2, -0.2, 0}}, 0.2],
Cylinder[{{-0.2, -0.2, 0}, {1, 1, 0}}, 0.2],
Scale[Cylinder[{{-0.05, 0.125, 0}, {0.5, -1, 0}}, 0.25], {1, 1,0.8}]
}]


results in the following output

Obviously, the remaining "stumps" of the cylinder segments on the respective other side of the reflection plane need to be removed. I do not want to go to too complex approaches like using Parametric surfaces or similar mathematical descriptions of a cylindrical segment, mainly for performance reasons (all of these methods are getting rather slow to plot). There is an interesting method documented in MathWorld, but the link to the ExtraPackagesHidekazuKnife package is broken, and the more recent link ends in 2007 too (checked through Wayback).

Maybe there are much simpler hacks to remove the unwanted cylinder areas?

Graphics3D[{Polygon[{{-1.5, -1.5, 0}, {1.5, -1.5, 0}, {1.5, 1.5,
0}, {-1.5, 1.5, 0}}],
Polygon[{{-1.5, 0, -1.5}, {1.5, 0, -1.5}, {1.5, 0, 1.5}, {-1.5, 0,
1.5}}], Opacity[0.5],
GeometricTransformation[Cylinder[{{-1, 1, 0}, {0.0, 0, 0}}, 0.2],
ShearingTransform[ -Pi/4, {-1, 1, 0}, {1, 1, 0}]],
GeometricTransformation[Cylinder[{{0, 0, 0}, {1, 1, 0}}, 0.2],
ShearingTransform[ -Pi/4, {1, 1, 0}, {-1, 1, 0}]],
Scale[
GeometricTransformation[
Cylinder[{{0, 0, 0}, {0.5, -1, 0}}, 0.25],
ShearingTransform[ -ArcTan[1/2.], {.5, -1, 0}, {-1, -.5, 0}]], {1,
1, 0.8}]}]


The shearing angles are calculated by hand from the specific incident and refracted angles you used. It could of course be automated, too.

To shear the caps of the cylinders without deforming the cylinder cross section, the first argument of ShearingTransform has to be a vector along the cylinder axis, and the second argument points perpendicular to the ray (in the plane of incidence).

• +1 a really nice idea. Exactly what I looked for May 8, 2013 at 18:48

Since your are simulating Light, why not use Tube

tube1IncidentAndReflection={{-1,1,0},{0,0,0},{1,1,0}};
tube2IncidentAndRefraction={{-1,1,0},{0,0,0},{.6,-1,0}};
Graphics3D[{Polygon[{{-1.5,-1.5,0},{1.5,-1.5,0},{1.5,1.5,0},{-1.5,1.5,0}}],Polygon[{{-1.5,0,-1.5},{1.5,0,-1.5},{1.5,0,1.5},{-1.5,0,1.5}}],Opacity[0.5],Tube[tube1IncidentAndReflection],Tube[tube2IncidentAndRefraction]}]


And you can set the JoinForm， amr's remind of CapForm .

So still some problem described as Jens' comment

• But this doesn't hide the intersecting caps properly at the branch point, which is the main point of the question. You can see this more clearly by increasing the Tube radius in your example.
– Jens
May 8, 2013 at 17:20
• remember there is also CapForm`
– amr
May 8, 2013 at 18:21
• @amr, yes, me silly, hehe May 9, 2013 at 2:16