0

This problem is asking the same as this problem, but is a cuboid instead of a cube and the independant variables are the roll, pitch, and yaw. I wrote some Mathematica code that finds the area numerically.

Here is the Mathematica code:

    randomEdgeLengths={RandomReal[{0,5}],RandomReal[{0,5}],RandomReal[{0,5}]}; 
    w=randomEdgeLengths[[1]];
    l=randomEdgeLengths[[2]];
    h=randomEdgeLengths[[3]];
    vertices=Flatten[Table[{x*l, y*w, z*h}, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}], 2];
(* vertices = {{0,0,0},{0,0,h},{0,w,0},{0,w,h},{l,0,0},{l,0,h},{l,w,0},{l,w,h}} *)
    α = RandomReal[{0,2π}];
    β = RandomReal[{0,2π}];
    γ = RandomReal[{0,2π}];
    rotationMatrixTransorm = RollPitchYawMatrix[{α, β, γ}];
    rotatedBoxPoints=Dot[vertices,rotationMatrixTransorm];
    (* Just matrix multiplication directly above *)
    xyProjectionPoints=Drop[rotatedBoxPoints,0,-1];
(*Removes the third coordinate of each element for a projection*)
    silouetteArea= Area[ConvexHullRegion[xyProjectionPoints]]

A Mathematica demonstration using different code gives a visualization of the same problem here.

 - Vertices = $\left(
\begin{array}{ccc}
 0 & 0 & 0 \\
 0 & 0 & h \\
 0 & w & 0 \\
 0 & w & h \\
 l & 0 & 0 \\
 l & 0 & h \\
 l & w & 0 \\
 l & w & h \\
\end{array}
\right) $
 - Rotation Matrix = $\left(
\begin{array}{lll}
 \cos (\alpha ) \cos (\beta ) & \sin (\alpha ) (-\cos (\beta )) & \sin (\beta ) \\
 \cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin (\alpha ) \cos (\gamma ) & \cos
   (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma ) & -\cos
   (\beta ) \sin (\gamma ) \\
 \sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma ) & \sin
   (\alpha ) \sin (\beta ) \cos (\gamma )+\cos (\alpha ) \sin (\gamma ) & \cos (\beta
   ) \cos (\gamma ) \\
\end{array}
\right) $
 - Rotation Box Points = $\left(
\begin{array}{lll}
 0 & 0 & 0 \\
 h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma )) & h
   (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos (\alpha ) \sin (\gamma )) & h
   \cos (\beta ) \cos (\gamma ) \\
 w (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin (\alpha ) \cos (\gamma )) & w
   (\cos (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma )) & -w
   \cos (\beta ) \sin (\gamma ) \\
 h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma ))+w
   (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin (\alpha ) \cos (\gamma )) & h
   (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos (\alpha ) \sin (\gamma ))+w
   (\cos (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma )) & h
   \cos (\beta ) \cos (\gamma )-w \cos (\beta ) \sin (\gamma ) \\
 l \cos (\alpha ) \cos (\beta ) & -l \sin (\alpha ) \cos (\beta ) & l \sin (\beta )
   \\
 h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma ))+l \cos
   (\alpha ) \cos (\beta ) & h (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos
   (\alpha ) \sin (\gamma ))-l \sin (\alpha ) \cos (\beta ) & h \cos (\beta ) \cos
   (\gamma )+l \sin (\beta ) \\
 l \cos (\alpha ) \cos (\beta )+w (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin
   (\alpha ) \cos (\gamma )) & w (\cos (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin
   (\beta ) \sin (\gamma ))-l \sin (\alpha ) \cos (\beta ) & l \sin (\beta )-w \cos
   (\beta ) \sin (\gamma ) \\
 h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma ))+l \cos
   (\alpha ) \cos (\beta )+w (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin
   (\alpha ) \cos (\gamma )) & h (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos
   (\alpha ) \sin (\gamma ))-l \sin (\alpha ) \cos (\beta )+w (\cos (\alpha ) \cos
   (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma )) & h \cos (\beta ) \cos
   (\gamma )+l \sin (\beta )-w \cos (\beta ) \sin (\gamma ) \\
\end{array}
\right) $
  • xyProjectionPoints = $\left(

\begin{array}{ll} 0 & 0 \ h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma )) & h (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos (\alpha ) \sin (\gamma )) \ w (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin (\alpha ) \cos (\gamma )) & w (\cos (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma )) \ h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma ))+w (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin (\alpha ) \cos (\gamma )) & h (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos (\alpha ) \sin (\gamma ))+w (\cos (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma )) \ l \cos (\alpha ) \cos (\beta ) & -l \sin (\alpha ) \cos (\beta ) \ h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma ))+l \cos (\alpha ) \cos (\beta ) & h (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos (\alpha ) \sin (\gamma ))-l \sin (\alpha ) \cos (\beta ) \ l \cos (\alpha ) \cos (\beta )+w (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin (\alpha ) \cos (\gamma )) & w (\cos (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma ))-l \sin (\alpha ) \cos (\beta ) \ h (\sin (\alpha ) \sin (\gamma )-\cos (\alpha ) \sin (\beta ) \cos (\gamma ))+l \cos (\alpha ) \cos (\beta )+w (\cos (\alpha ) \sin (\beta ) \sin (\gamma )+\sin (\alpha ) \cos (\gamma )) & h (\sin (\alpha ) \sin (\beta ) \cos (\gamma )+\cos (\alpha ) \sin (\gamma ))-l \sin (\alpha ) \cos (\beta )+w (\cos (\alpha ) \cos (\gamma )-\sin (\alpha ) \sin (\beta ) \sin (\gamma )) \ \end{array} \right) $

UPDATED SOLUTION (This is the HosamH's genius solution):

    randomEdgeLengths={RandomReal[{0,5}],RandomReal[{0,5}],RandomReal[{0,5}]}; 
    w= RandomReal[{0,5}];
    l=RandomReal[{0,5}];
    h=RandomReal[{0,5}];
    vertices=Flatten[Table[{x*l, y*w, z*h}, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}], 2];
    α  = RandomReal[{0,2π}];
    β = RandomReal[{0,2π}];
    γ = 0; (* Can be generalized easily enough *)
    rotationMatrixTransorm =Transpose[ RollPitchYawMatrix[{β, α , 0},{3,2,1}]];
    rotatedBoxPoints=Dot[vertices,rotationMatrixTransorm];
    xyProjectionPoints=Drop[rotatedBoxPoints,0,-1];
    silouetteArea= {Area[ConvexHullRegion[xyProjectionPoints]],
w*h*Abs[Sin[α]Cos[β]]+l*h*Abs[Sin[α]Sin[β]]+w*l*Abs[Cos[α]] }

1 Answers1

1

As derived in the solution of this problem, the expression, after adapting the expression for different side lengths $w, l , h$, we have (Assuming that before the rotations, $l$ is along the $x$ axis, $w$ is along the $y$ axis, and $h$ is along the $z$ axis):

$ A(\theta_1, \theta_2) = w h | \sin \theta_1 \cos \theta_2 | + l h | \sin \theta_1 \sin \theta_2 | + w l | \cos \theta_1 | $

Since $ u = [ |\sin \theta_1 \cos \theta_2 | , | \sin \theta_1 \sin \theta_2 | , | \cos \theta_1 | ]^T$ is a unit vector, then it follows by the Cauchy-Schwarz inequality that

$ A \le \sqrt{ w^2 h^2 + l^2 h^2 + w^2 l^2 } $

i.e.

$ A_{Max} = \sqrt{ w^2 h^2 + l^2 h^2 + w^2 l^2 } $

which is attainable by proper choice of $\theta_1$ and $\theta_2$.

  • Why do you not need a third angle? – Teg Louis Jul 27 '23 at 22:07
  • 1
    Because you're projecting the cuboid onto the $xy$ plane, so a third rotation about the (world) $z$ axis does not change the projected area, and is therefore unnecessary. –  Jul 27 '23 at 22:09
  • I am missing something. Does it need to be centered around the origin? Or is it a corner at the origin? And which one is which angle? I am sorry for asking so much. I will accept and apply to bounty once I can test it. – Teg Louis Jul 27 '23 at 23:32
  • 1
    The location of the center does not change the formula for the projected area, because the point about which the rotation is carried out does not change the orientation of the rotated cuboid. –  Jul 27 '23 at 23:36
  • You're using a different parameterization from the one I am using which is explained in the referenced answer. –  Jul 28 '23 at 01:07
  • 1
    I looked the syntax for the Mathematica function RollPitchYawMatrix, and there is another call type which is $\text{RollPitchYawMatrix}[{\alpha, \beta, \gamma}, {a,b,c}]$, which rotates by $\alpha$ about fixed axis $a$, then by $\beta$ about fixed axis $b$, then by $\gamma$ about fixed axis $c$. In our case, we're rotating about relative not fixed axes, so the order of the first two parameters has to be reversed. So, $a=[0, 1, 0]$ and $\alpha = \theta_1$, and $b = [0, 0, 1]$ and $\beta = \theta_2$, so the call will be $\text{RollPitchYawMatrix}[{\beta, \alpha, 0}, {b, a, c}]$. –  Jul 28 '23 at 01:21
  • I still can't figure it out. I am okay with not using Mathematica. But when I use the matrix in your answer in the other post, I still don't get the correct answer, but is numerically close. It makes sense that there are three terms with the area of each square being times by a trig function, since that is what you see when you rotate. But I still can't seem to get it to work. – Teg Louis Jul 28 '23 at 14:14
  • My question on Mathematica shows the format of the answer using the original matrix. – Teg Louis Jul 28 '23 at 19:02
  • I don't know the Mathematica language. But if you use your Mathematica code as I mentioned in my previous comment, you should get exactly the same values as computed by Mathematica and as given by the formula in my answer. Thank you for accepting my answer. –  Jul 28 '23 at 19:34
  • I am going to award you the bounty. But honestly I cannot get the exact same answers. And when I used a matrix on your post instead of the one in Mathematica, I didn't get an exact either. It was just a very close approximation most of the time. But it was enough confirmation that I will be able to connect the dots. I don't care if the answer uses Mathematica or not, just wanted to verify with something. – Teg Louis Jul 28 '23 at 20:55
  • I believe the error is in your usage of Flatten or other functions in your code. I couldn't understand what Flatten does exactly from the documentation on the web about it. So please check the proper usage of Flatten and also the other functions that you're calling in your code. –  Jul 28 '23 at 23:52
  • Flatten just removes a layer of {}, Flatten... 2 is for the second layer. The code is correct. I showed what the matrix is and the result of flatten. – Teg Louis Jul 29 '23 at 00:17
  • Try using $\text{RollPitchYawMatrix}[{\beta, \alpha, 0]}, {b, a, c} ]$ where $\beta = \theta_2$ and $\alpha = \theta_1$, $a = {0,1,0} $ and $b = {0, 0, 1}$ and $c$ is any vector. The resulting projected cube area should be exactly equal to the value obtained from the formula, namely, $A = w h | \sin \alpha \cos \beta | + l h | \sin \alpha \sin \beta | + l w | \cos \alpha | $ –  Jul 29 '23 at 01:08
  • 1
    Also, how does $Dot$ work?? is it multiplying the vertices with the columns or rows of rotationMatrixTransform ?? This is important. Because if its multiplying by the columns then you have to TRANSPOSE the matrix rotationMatrixTransform and store it in a different matrix, say rotationMatrixTransformTr, and then find the rotated vertices as follows: $\text{rotatedBoxPoints = Dot[vertices, rotationMatrixTransformTr] }$ –  Jul 29 '23 at 01:38
  • Thank you for your patience. I will show what it does. It is very possible that I overlooked something under the hood. I will post what each step does. I tried switching beta and alpha, and playing around with the second ${b,a,c}$. They don't take vectors of that form persay, they use integers from 1 to 3 to do it. I am not really great at visualizing things. – Teg Louis Jul 30 '23 at 16:13
  • When I show the latex it is too big, so I place it as code so it fits in a scrollable box. I will try using the TRANSPOSE and see if that works. Thank you. – Teg Louis Jul 30 '23 at 16:33
  • 1
    Sorry about my ignorance. So, the call has to be modified to $\text{RawPitchYawMatrix[{ \theta_2, \theta_1,0},{3,2,1}]}$ –  Jul 30 '23 at 16:35
  • Ok, thanks for the quick reply. And you don't have to apologize. You are more knowledgeable about mathematics than me. I move boxes for a living after teaching overseas, so I just got interested in the mathematics behind it. I just try to do explain my best. – Teg Louis Jul 30 '23 at 16:37
  • 1
    So, the call has to be modified to $\text{RawPitchYawMatrix}[{ \theta_2, \theta_1,0},{3,2,1}]$ –  Jul 30 '23 at 16:41
  • Please let me know if this works, also after making sure Dot is doing what it is intended to do. –  Jul 30 '23 at 16:43
  • YAY!!!!!!!! It works. You are a genius! If I was rich I would pay you a lot. I am going to post the corrected Mathematica as an update underneath the OP. I didn't think to do a transpose. I will be more careful next time. – Teg Louis Jul 30 '23 at 16:55
  • 1
    That's great. I am really glad it worked. Cheers!!! –  Jul 30 '23 at 16:59