I'm trying to calculate the sum of the shadows that a cylinder can make when rotated through both theta and phi.

I have the following code:

dia = 1;
length = 2;
dstart = -length;
dmat = N@4/200;
SamplingMatrix = ConstantArray[0,{201,201}];
  cyl = Cylinder[
      {-length/2 * Cos[theta], 0, -length/2 * Sin[theta]},
      {length/2 * Cos[theta], 0, length/2 * Sin[theta]}
  g = Resolve[Exists[z,{x,y,z}\[Element]cyl],Reals];
  f = ImplicitRegion[g,{x,y}];
        SamplingMatrix[[i,j]] = SamplingMatrix[[i,j]] + 1;,

Which is clunky but it works. I then use the following to rotate the results from this to obtain the full radial distribution (using the function from here):

SamplingMatrix = SamplingMatrix + SquareMatrixRotate[rotatematrix,phi];

This seems to give a satisfactory result, but it definitely feels like I'm using a club to solve a problem that should have a more elegant solution. Is there a better way to do this? To be clear, I'm not a mathematician, so this could very well be a trivial problem which has a known solution. If so, I would appreciate it if someone would point me in the right direction.


EDIT 1 I included the following image to show the output that I'm looking for: Scattering Cross Section of Randomly Oriented Cylinder

EDIT 2 Revised the title to better reflect the nature of my problem

  • $\begingroup$ I would expect a Circle[{0,0},Sqrt[5/4]] ? $\endgroup$ Mar 24, 2020 at 17:03
  • $\begingroup$ I that should give the bulk shadow area? But I'm looking for the sum of the shadow areas. ie. If you take a snapshot each time you rotate all the cylinders, and sum the snapshots, what does that look like. $\endgroup$ Mar 24, 2020 at 17:16

2 Answers 2


The shadow of a cylinder is two half-ellipses and the shadow of a rectangle at an angle. Under the reasonable assumption that the light rays of the sun are perpendicular to the flat ground, the two half-ellipses are two halves of the same ellipse, and the shadow of the rectangle is another rectangle. In other words, you don't have to take "perspective" into account, because the shadow is an orthogonal projection of the cylinder.

This reduces your task to finding the ellipse and the rectangle corresponding to the shadow of the cylinder at an angle $\theta$ to the ground, which you can probably solve. Once you do that, use the grade school formulas for the areas and add.

I now prove that rotating a circle gives you an ellipse. You need three facts from geometry.

First, for a vector $\hat{v} = \begin{bmatrix}x\\ y\\ z \end{bmatrix}$, you can rotate the vector about, say, the $x$-axis by multiplying it by the rotation matrix

$$R_\theta = \begin{bmatrix}1 & 0 & 0\\ 0 & \cos \theta & -\sin \theta\\ 0 & \sin \theta & \cos \theta \end{bmatrix}.$$

Second, the set of all vectors of the form

$$\hat{v} = \begin{bmatrix}x\\ y\\ z \end{bmatrix}$$

having $x^2 + y^2 = r^2$ and $z=z_0$ (a constant) are exactly the set of points in a circle that is parallel to the $xy$-plane with radius $r$. (Notice that $z$ is a constant equal to the distance the circle is above the ground.)

Finally, conveniently, for any vector $\hat{v} = \begin{bmatrix}x\\ y\\ z \end{bmatrix}$, the projection of that vector onto the ground (the $xy$-plane) is just $\text{proj}(\hat{v})= \begin{bmatrix}x\\  y\\ 0 \end{bmatrix}$, i.e. set the $z$-coordinate to zero.

Let's use $R_\theta$ with our circle vector and then project onto the ground:

$$R_\theta\; \hat{v} = \begin{bmatrix}1 & 0 & 0\\ 0 & \cos \theta & -\sin \theta\\ 0 & \sin \theta & \cos \theta \end{bmatrix}\begin{bmatrix}x\\ y\\ z \end{bmatrix} = \begin{bmatrix}x\\ y \cos \theta - z \sin \theta \\ y \sin \theta + z \cos \theta \end{bmatrix},$$ giving $$\text{proj}\left( R_\theta\; \hat{v} \right) = \begin{bmatrix}x\\ y \cos \theta \\ y \sin \theta\end{bmatrix}.$$ (Remember, we set the $z$-coordindate to zero, not the $\tilde{z}$-coordinate.)

Let's name the rotated coordinates:

$$R_\theta\; \hat{v} = \begin{bmatrix}\tilde{x}\\ \tilde{y}\\ \tilde{z} \end{bmatrix} = \begin{bmatrix}x\\ y \cos \theta - z \sin \theta \\ y \sin \theta + z \cos \theta \end{bmatrix}$$.

Now the question is, if we trace out a circle in the rotated $\tilde{x}\tilde{y}$-coordinates, i.e. if $\tilde{x}^2 + \tilde{y}^2 = r^2$ for $\tilde{x}=x$ and $\tilde{y} = y \cos \theta - z \sin \theta$ , what do we have for the projection in $x$-$y$ coordinates? We compute:

$$r^2=\tilde{x}^2 + \tilde{y}^2 = x^2 + (y \cos \theta - z \sin \theta)^2$$.

Projecting by setting $z$ to zero gives $x^2 + (\cos^2 \theta)\,y^2 = r^2,$ an ellipse, or a line if $\cos \theta = 0$.

  • $\begingroup$ Is the shape really an ellipse, or is it a Vesica Piscis? When I looked at solving the problem in the way you described, I wasn't able to satisfactorily show that it was one or the other. $\endgroup$ Mar 24, 2020 at 17:13
  • $\begingroup$ So, I took another crack at it, and you're correct that it's an ellipse. I compared the analytical formula to the results I got from my brute force code, and they match in terms of area. Once you have this though, it needs to be translated into an area distribution, like I show in my image. I feel like this is an integral, but I can't figure out how to express it. $\endgroup$ Mar 24, 2020 at 19:56
  • $\begingroup$ I'm not entirely understanding your problem. There is only one angle that matters to the area of the shadow: the angle between the cylinder's axis and the ground. So whatever you are graphing should be dependent on that variable alone. Your graph appears to be a plot over space (xy-coords), not a plot over angles. If you are trying to determine how much solar power is absorbed at each point, that's a different problem from determining the power absorbed (or blocked) over all points simultaneously. $\endgroup$ Mar 24, 2020 at 20:58
  • $\begingroup$ I agree with your proof. Your equation is what I obtained (though I used much less rigorous methods). I believe I have stated my problem poorly. In reality, what I'm looking for is not really the shadow, but the scattering cross section of a randomly oriented cylinder. ie. If we have an incoming photon, what is the probability that it will be absorbed by the cylinder, given that the cylinder's orientation is not known a priori. The graph I've posted is looking at the XY plane, with the intensity indicating the probability of striking the cylinder. $\endgroup$ Mar 24, 2020 at 21:05
  • $\begingroup$ Scattering depends on incident angle to the surface and on the angle of the observer, so the projection of the cylinder onto the ground is irrelevant. $\endgroup$ Mar 24, 2020 at 22:25

Here a faster solution without Do using RegionPlot3D

First define cylinder (rotation [CurlyPhi] around {1,0,0} )

zyl[\[CurlyPhi]_] :=Cylinder[{-{0, -Sin[\[CurlyPhi]],Cos[\[CurlyPhi]]}, {0, -Sin[\[CurlyPhi]], Cos[\[CurlyPhi]]}},1/2]

Second list of 3D-regions

zi = Table[DiscretizeRegion[ zyl[\[CurlyPhi]],MaxCellMeasure -> Pi/2/500], {\[CurlyPhi],Subdivide[-Pi, Pi, 10]}] ;

Third 3d-Plot projected into plane {1,0,0},{0,1,0}

Show[{Map[RegionPlot3D, zi ] ,ParametricPlot3D[Sqrt[5/4] {Cos[t], Sin[t], 0}, {t, -Pi, Pi}]},ViewVector -> {1000 e3, 0 e3} ]

enter image description here

Rotation of this region gives a Circle[{0,0},Sqrt[5/4]] as the final result for the shadow you are looking for!


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.