1
$\begingroup$

I am experimentally trying to solve this problem about the projected area of a cuboid. I sense patterns when I run the below code, but it is difficult for me to compare them. Here is the code:

w=29;l=13;h=11;
vertices = Flatten[Table[{x*l, y*w, z*h}, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}], 2];
 Manipulate[
      rotationMatrixTransorm = RollPitchYawMatrix[{α, β, γ}]; 
      rotatedBoxPoints = Dot[vertices,rotationMatrixTransorm];
      xyProjectionPoints = Drop[rotatedBoxPoints,0,-1];
      silouetteArea= Area[ConvexHullRegion[xyProjectionPoints]],
     {α, 0, 2Pi,Pi/20, Appearance -> "Open"},
     {β, 0, 2Pi,Pi/20, Appearance -> "Open"},
     {γ, 0, 2Pi,Pi/20, Appearance -> "Open"}
   ]

My thought is to have the solution in terms of just sine and cosine, so that it gives a solution of the form (I think the solution can be written in the form): $$\sum{(\text{face area})\cos(\alpha)^q\cos(\beta)^r\cos(\gamma)^s}$$ Also, I know that when the width, length, and height are distinct primes, it is easier to detect patterns. But some parts evaluates into just numbers or they swap between cosine and sine.

Defer and HoldForm seem like useful for this, but I cannot figure out the syntax.

$\endgroup$

1 Answer 1

2
$\begingroup$

It is likely not the most elegant solution, but you may try the following:

rpyMat = Inactivate[Evaluate[RollPitchYawMatrix[{a, b, c}]], Sin | Cos];
w = 29; l = 13; h = 11;
vertices = Flatten[Table[{x*l, y*w, z*h}, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}], 2];

Manipulate[
 Module[{rotationMatrixTransorm, rotatedBoxPoints, xyProjectionPoints,
    xyProjectionPointsActivated, cHull, pos},
  rotationMatrixTransorm = rpyMat /. {a -> α, b -> β, c -> γ};
  rotatedBoxPoints = Dot[vertices, rotationMatrixTransorm];
  xyProjectionPoints = Drop[rotatedBoxPoints, 0, -1];
  xyProjectionPointsActivated = Activate[xyProjectionPoints];
  cHull = ConvexHullRegion[xyProjectionPoints // Activate];
  pos = FirstPosition[xyProjectionPointsActivated, #] & /@ First@cHull;
  Area[Polygon[xyProjectionPoints[[Flatten@pos]]]] // Expand
  ]
 ,
 {α, 0, 2 Pi, Pi/20, Appearance -> "Open"},
 {β, 0, 2 Pi, Pi/20, Appearance -> "Open"},
 {γ, 0, 2 Pi, Pi/20, Appearance -> "Open"}
 ]

enter image description here

In this code, separated copies of points are used, one with activated trigonometric functions (xyProjectionPointsActivated, which are needed to calculate the convex hull), and one with the $\sin$ and $\cos$ kept intact (xyProjectionPoints). After calculating the convex hull, you extract which points generate the hull, and use their inactivated forms to calculate the area.

You can of course do further algebraic processing on the final expression.

$\endgroup$
1
  • $\begingroup$ Your solution most certainly makes it much easier to see patterns though. There is absolutely no way I would have figured out to use the syntax on the top line myself. $\endgroup$
    – Teg Louis
    Commented Jul 28, 2023 at 18:29

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.