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.

I have the following code, giving me a representation of a photon hitting a cylinder:

scale1 = 1.2;
scale2 = 2.25;
scale3 = 1.4;
scale4 = 2;
inp = {scale2, scale2, scale2};
intp = {4, 4, 3};
rainp = {4, 0, 0};
raoutp = {4, 8/scale3, 6/scale3};
outp = {4, 4.65, 3.25};
ninra = (intp - inp)\[Cross](raoutp - rainp);
inttan = (raoutp - rainp) - inp;
tandir = (raoutp - rainp)\[Cross] ninra;
tanvect[t_] := inp + t*tandir;
tanvect1 = tanvect[0.15];
v = tandir;
u = raoutp - rainp;
w = rainp - inp;
s = (v[[2]]*w[[1]] - v[[1]]*w[[2]])/(v[[1]]*u[[2]] - v[[2]]*u[[1]]);
t = (u[[1]]*w[[2]] - u[[2]]*w[[1]])/(u[[1]]*v[[2]] - u[[2]]*v[[1]]);
d = EuclideanDistance[inp, tanvect1]*t;
p = tanvect[2*t];

nareaR = ({1, 0, 0}\[Cross]((rainp - raoutp)/Norm[{raoutp - rainp}]));
nareaR = nareaR/Norm[nareaR];

cylinder = 
  ContourPlot3D[y^2 + z^2 == 25, {x, 0, 10}, {y, -5, 5}, {z, -5, 5}, 
  Mesh -> None, ContourStyle -> Directive[Brown, Opacity[0.25]], 
  AxesLabel -> {"x", "y", "z"}];
areaX = 
  ContourPlot3D[x == 4, {x, 2, 7}, {y, 2, 7}, {z, 0, 5}, 
  Mesh -> None, ContourStyle -> Directive[White, Dashed, Opacity[0]],
  AxesLabel -> {"x", "y", "z"}];
areaR = 
  Plot3D[
    (nareaR[[1]]*intp[[1]] + nareaR[[2]]*intp[[2]] + nareaR[[3]]*intp[[3]] -
     nareaR[[1]]*x - nareaR[[2]]*y)/(nareaR[[3]]), 
    {x, 2, 7}, {y, 2, 7}, 
    Mesh -> None,
    PlotStyle -> Directive[White, Dashed, Opacity[0]], 
    AxesLabel -> {"x", "y", "z"}];
axial = 
  Graphics3D[{Arrowheads[0.02], Black, Dashed, Arrow[{{0, 0, 0}, {10, 0, 0}}], 
    AxesLabel -> {"x", "y", "z"}}];
radius = 
  Graphics3D[{Arrowheads[0.02], Black, Dashed, Arrow[{rainp, raoutp}], 
    AxesLabel -> {"x", "y", "z"}}];
inv = 
  Graphics3D[{Thick, Arrowheads[0.02], Red, Arrow[{inp, intp}], 
    AxesLabel -> {"x", "y", "z"}}];
outv = 
  Graphics3D[{Thick, Arrowheads[0.02], Blue, Arrow[{intp, scale1*outp}], 
    AxesLabel -> {"x", "y", "z"}}];
reflv = 
  Graphics3D[{Thick, Arrowheads[0.02], Green, Arrow[{{4, 4, 3}, p}], 
    AxesLabel -> {"x", "y", "z"}}];
directCos1 = 
  Graphics3D[{Arrowheads[0.02], Purple, Dashed, Thick, 
    Line[{{4, 4, 3}, {4, scale1*4.65, 3}, {4, scale1*4.65, 3}, 
          {4, scale1*4.65, scale1*3.25}, {4, scale1*4.65, scale1*3.25}, 
          {scale1*4, scale1*4.65, scale1*3.25}}], 
    AxesLabel -> {"x", "y", "z"}}];
directCos2 = 
  Graphics3D[{Arrowheads[0.02], Orange, Dashed, Thick, 
    Line[{{scale2*1, scale2*1, scale2*1}, {scale2*1, scale2*1, 3}, 
          {scale2*1, scale2*1, 3}, {scale2*1, 4, 3}, {scale2*1, 4, 3}, 
          {4, 4, 3}}], 
    AxesLabel -> {"x", "y", "z"}}];
directCosReflv = 
  Graphics3D[{
    Arrowheads[0.02], Cyan, Dashed, Thick, 
    Line[{{4, 4, 3}, {4, p[[2]], 3}, {4, p[[2]], 3}, 
          {p[[1]], p[[2]], 3}, {p[[1]], p[[2]], 3}, {p[[1]], p[[2]], p[[3]]}}], 
    AxesLabel -> {"x", "y", "z"}}];
Show[
  directCos1, directCos2, directCosReflv, radius, outv, axial, 
   inv, reflv, areaR, areaX, cylinder, 
  Axes -> False, 
  AxesLabel -> {"x", "y", "z"}, 
  Boxed -> False]

By setting the viewpoint option in Show to be:

ViewPoint -> {∞, 0, 0}

I get a nice representation in the y,z plane.

My question is how do I easily project the cylinder and its vectors onto the r,x plane?

share|improve this question
2  
What is r x plane? –  Kuba Jul 24 '13 at 6:08
    
In my problem the rx-plane is given by: x: the axial direction of the cylinder r: the radius of the cylinder intp: the vector where the photon strikes the boundary areaR defines the rx-plane which is of interest for my problem. The question is how to project the whole 3D Graphics onto the areaR plane. –  user8698 Jul 24 '13 at 8:50
    
Notice, that 90% of your code is not important in context of the question. Next time, please, post the minimal example of self consistent code. :) –  Kuba Jul 24 '13 at 8:58

1 Answer 1

If you want to see projection on r-x plane you can set:

ViewPoint - > 1000 Cross[x,r]

with assumption that x and r are not parallel. Cross by definition gives you vector normal to the plain stretched by x and r and 1000 is close enough to Inf.

It is really annoying that r is not connected with your code and the point we must know is called intp...

Projection is set, now you may want to set it straight, use ViewVertical:

Show[directCos1, directCos2, directCosReflv, radius, outv, axial, inv, 
     reflv, areaR, areaX, cylinder, Axes -> False, AxesLabel -> {"x", "y", "z"},
     Boxed -> False, 
     ViewPoint -> 1000 Cross[{1, 0, 0}, intp], ViewVertical -> {0, 1, 0}]

enter image description here

share|improve this answer
    
I wasn't aware of ViewVertical Thanks! –  user8698 Jul 24 '13 at 10:05
    
@user8698 You are welcome, but it is only an improvement, projection is done be ViewPoint. –  Kuba Jul 24 '13 at 10:06
    
I know, I used ViewPoint already with the normal vector of areaR but ViewPoint was missing to get the plot I wanted! Thank you once more! –  user8698 Jul 24 '13 at 12:26

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.