# Creating a dynamic list with different subset lengths in while loop

I am trying to create 2D list or table in a while loop as below:

rotateparametric[parfunc_, fixedpoint_, angle_] :=
RotationMatrix[angle].(parfunc - fixedpoint) + fixedpoint;
viewAngle = Pi/3;
ctrVolume = {(Exp[(Pi - viewAngle)*0.5] + 1)/2, 0};
radiusVolume = (Exp[(Pi - viewAngle)*0.5] - 1)/2;
radiusRing = (Exp[(Pi - viewAngle)*0.5] + 1)/2;
FPS = 720;
fPlanet = 5;
fOrbit = 9;
planetRotation =
0}, -2*Pi*i*fPlanet/FPS]
mirrorPlanetRotation =
0}, Pi - 2*Pi*i*fPlanet/FPS]
orbitRotation =
rotateparametric[planetRotation, ctrVolume, +2*Pi*i*fOrbit/FPS]
mirrorOrbitRotation =
rotateparametric[planetRotation, ctrVolume, Pi + 2*Pi*i*fOrbit/FPS]
TheCurves = Evaluate@Table[orbitRotation, {i, 1, FPS}];
TheMirrorCurves = Evaluate@Table[mirrorOrbitRotation, {i, 1, FPS}];
pp = ParametricPlot[{TheCurves, TheMirrorCurves}, {t, 0,
Pi - viewAngle},
RegionFunction -> (Norm[{#, #2} - ctrVolume] <= radiusVolume &),
PlotRange -> All]
discreteBounderFraction = 5;
xDisBounList =
Table[ctrVolume[[1]] - radiusVolume + (i - 1)*discreteBounder, {i,
discreteBounderFraction*2 + 1}]
yDisBounList =
Table[ctrVolume[[2]] - radiusVolume + (i - 1)*discreteBounder, {i,
discreteBounderFraction*2 + 1}]
xyDisBounList = Tuples[{xDisBounList, yDisBounList}]
xyDisBounListInVolume =
Position[xyDisBounList, {x_,
y_} /; ((x - ctrVolume[[1]])^2 + (y - ctrVolume[[2]])^2 <=
radiusVolume^2 && (x + discreteBounder -
ctrVolume[[1]])^2 + (y - ctrVolume[[2]])^2 <= radiusVolume^2
&& (x - ctrVolume[[1]])^2 + (y + discreteBounder -
ctrVolume[[2]])^2 <=
radiusVolume^2 && (x + discreteBounder -
ctrVolume[[1]])^2 + (y + discreteBounder -
curves = Table[
Table[TheCurves[[k]], {t, 0, Pi - viewAngle,
discreteBounderFraction/5}], {k, 1, FPS}];
mirrorCurves =
Table[Table[
TheMirrorCurves[[k]], {t, 0, Pi - viewAngle,
discreteBounderFraction/5}], {k, 1, FPS}];
arctans =
Table[ArcTan @@@ Normalize /@ Differences[curves[[k]]], {k, 1, FPS}];
mirrorArctans =
Table[ArcTan @@@ Normalize /@ Differences[mirrorCurves[[k]]], {k, 1,
FPS}];
shortCurves = Table[Most@curves[[k]], {k, 1, FPS}];
shortMirrorCurves = Table[Most@mirrorCurves[[k]], {k, 1, FPS}];
n = 1;
While[n <= Length[xyDisBounListInVolume],
left = xyDisBounList[[xyDisBounListInVolume[[n]][[1]]]][[1]];
right = left + discreteBounder;
low = xyDisBounList[[xyDisBounListInVolume[[n]][[1]]]][[2]];
high = low + discreteBounder;
m = 1;
While[m <= FPS,
locations = pointsInVoxel[left, right, low, high, shortCurves[[m]]];
mirrorLocations =
pointsInVoxel[left, right, low, high, shortMirrorCurves[[m]]];
If[locations != {},
Append[VoxelCoverage[[
n]], {arctans[[m]][[First[locations]]] + Pi/2,
arctans[[m]][[Last[locations]]] + Pi/2}]];
If[mirrorLocations != {},
Append[VoxelCoverage[[
n]], {mirrorArctans[[m]][[First[mirrorLocations]]] + Pi/2,
mirrorArctans[[m]][[Last[mirrorLocations]]] + Pi/2}]];
m++];
n++]


The dynamic list supposed to be VoxelCoverage in this code.

What I was trying to do is to add new elements into the n'th subset in the loop. Therefore the list might be something like this:

{x,y}
{{x1,y1},{x2,y2}}
{{x3,y3},{x4,y4},{x5,y5},{x6,y6}}
{{x7,y7},{x8,y8}}


I tried Append operator but clearly it won't work. How can I do that?

This is a follow up question to this question on stack. What I'm trying to do here is to divide the volume as below:

If I can store the arctan values of the curves inside the discreteBounds(aka meshes) I will know the total view of the voxels. Think those curves as displays, like an LCD screen. LCD screens have viewing angles. So if the viewing angle is 100 degrees, and one voxels have 4 curves with arctan values Pi/4, 3Pi/4, -3Pi/4, -Pi/4, then that voxel is able to emit light in every direction. I tried to illustrate the logic below. I don't think I can be more clear:

From here, I will calculate the total viewing angle of every voxels in the holographic volume, then extract an histogram. If 90% of the voxels have moe than 300 degree viewing angle than I will consider myself succesful. Thanks.

• Code doesn't run (too many unset variables). – MikeY Apr 8 at 15:35
• You probably need AppendTo instead of Append. However, I have so far not seen any application of the AppendTo operator that led to good code. Try using Table or Sow & Reap instead. – Roman Apr 8 at 15:39
• @Alper91, I assume this is related to your other question...mathematica.stackexchange.com/questions/194428/… . What is the real goal? Might be able to restructure the approach, get you away from using a While loop in the first place. – MikeY Apr 8 at 16:34
• @MikeY Yes, I tried to put some more on to your answer but I am stcuk again. I edited the question to be more clear and explained every detal as much as I can. – Alper91 Apr 8 at 17:23