In the field of architecture, learning to manipulate geometry so comprehensively with Mathematica has been fun. However, I seem to have reached my limits with the following GeometricTransformation
of panels generated with the following code:
poly=Module[{div=6,len=16000,list,sqx,sqy,h=Table[{1+c,2+c,9+c,8+c},{c,0,40}],listy,listx},
list=Flatten[Table[{x,y,z},{x,0,len,len/div},{y,0,len,len/div},{z,0,len,len/div}],2];
sqy=Select[list,#[[1]]==0&];
sqx=Select[list,#[[2]]==0&];
listy=Drop[Part[sqy,#] &/@ h,{7,40,7}];
listx=Drop[Part[sqx,#] &/@ h,{7,40,7}];
Polygon/@ Join[listx,listy]];
What I'm trying to do next is to rotate each individual panel by some controllable degree, but instead the whole thing moves as one:
Graphics3D[GeometricTransformation[#, RotationMatrix[-Pi/8,{1,0,0}]] &/@ poly]
I've tried using RegionBounds
to somehow create a vector axis to rotate each individual panel around, but seem to get stuck in 1) creating the vector and 2) feeding each panel's rotation vector back into GeometricTransform
. Eventually I'd like to randomize the direction of the opening and generalize the function for any division of the surface but it's time to ask for help. Thanks.
Update: It occurred to me that I could include an image of the building to show the final geometry we are aiming for. (Here presented under a CC license credit:PeterBarr)
Update 18-03-18
Taking the below suggestions as a starting point, I've decided to 1) angle the plane outward and 2) randomly select one of the 4 edges to use as an axis in one step. I've worked out the geometry of such an approach which needs to take into account which vertex of the plane is randomly selected to then assign the correct vector direction. I should be able to develop a list to feed into the RotationTransform
however when trying to execute my RandomChoice function, only the geometry of the first polygon is used 10 times. Very strange. Any suggestions?
x1={{0,0,1},#[[1,1]]};x2={{1,0,0},#[[1,2]]};x3={{0,0,-1},#[[1,3]]};x4={{-1,0,0},#[[1,4]]};
RandomChoice[{v1,v2,v3,v4}] &/@ poly[[;;]]
Final Update 18-03-21
After a little reverse engineering I got exactly what I wanted. Thanks for the help.
panel[f_]:=Module[{f1,f2,, \[Theta] = -Pi/5},
f1 =MakePolygons[Table[N[{x, 0, z}], {x, 0, f}, {z, 0, f}]];
f2=MakePolygons[Table[N[{0, y, z}], {y, 0, f}, {z, 0, f}]];
Table[Graphics3D[{spinPanel2[#, RandomInteger[{1, 4}], \[Theta]] &/@ f1,
spinPanel2[#, RandomInteger[{1, 4}], \[Theta]] &/@ f2},
ImageSize-> Small,Boxed->False,Lighting->"Neutral",ViewPoint->n],{n,{Front,{1,-2,2},{2,-3,2},{-5,1,2}}}]]