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}];
Do[
cyl = Cylinder[
{
{-length/2 * Cos[theta], 0, -length/2 * Sin[theta]},
{length/2 * Cos[theta], 0, length/2 * Sin[theta]}
},
dia/2
];
g = Resolve[Exists[z,{x,y,z}\[Element]cyl],Reals];
f = ImplicitRegion[g,{x,y}];
Do[
Do[
If[
RegionMember[f,{dstart+dmat*(i-1),dstart+dmat*(j-1)}],
SamplingMatrix[[i,j]] = SamplingMatrix[[i,j]] + 1;,
Unevaluated[Sequence[]]
],
{j,1,201}
]
,
{i,1,201}
],
{theta,0,Pi,Pi/180}
]
MatrixPlot[SamplingMatrix]
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):
Do[
SamplingMatrix = SamplingMatrix + SquareMatrixRotate[rotatematrix,phi];
,
{phi,pi/180,pi,pi/180}
]
MatrixPlot[SamplingMatrix]
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.
Thanks
EDIT 1 I included the following image to show the output that I'm looking for:
EDIT 2 Revised the title to better reflect the nature of my problem
Circle[{0,0},Sqrt[5/4]]
? $\endgroup$