Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

Mathematica Screenshot

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 ExtraPackages`Hidekazu`Knife` 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?

share|improve this question
add comment

2 Answers

up vote 14 down vote accepted

Use ShearingTransform:

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}]}]

sheared

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

share|improve this answer
    
+1 a nice idea ;) –  Vitaliy Kaurov May 8 '13 at 6:11
    
+1 a really nice idea. Exactly what I looked for –  Rainer May 8 '13 at 18:48
add comment

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 . enter image description here

enter image description here So still some problem described as Jens' comment

share|improve this answer
1  
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 '13 at 17:20
    
remember there is also CapForm –  amr May 8 '13 at 18:21
    
@amr, yes, me silly, hehe –  HyperGroups May 9 '13 at 2:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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