How to restrict the area inside a 3D-rotated Box.

99 Views Asked by At

First of all, sorry for the question.

I really didn't want to ask this kind of "bad" question since it must be something "obvious" I'm missing. But I have been trying to fix this for more than a day.

How the Box is described:

The box is described by 3x3 quantities: Starting position, Length, Rotation Angle and that's one quantity for each of the cartesian axes (x,y,z). Here is a Picture of how the Box is described (its through an Animation Tool).

What I want to express:

Basically I want to "trap" the space between that box. For Example if the box was simply parallel to the Axis I would just say $$ x_m ≤x≤ x_M $$ same thing for $y,z$

Now this is a harder case but that's what I want to achieve. $$ f(y,z) ≤x≤g(y,z) $$ as TomKern said.

What I have tried:

I have tried to rotate the three vectors defining the Box around original axis starting from x to z. (The order matters I think). Read about Eulerian Angles but still going to center of the box and rotating it with the same order didn't have much success from what I saw.

Maybe a silly idea: Trying to find "3" parallel surface that passes from the starting point, each one respecting the "other two" angles might work. For that I just need a way to express the normal of each of the 3 surfaces.

Sorry for the question

2

There are 2 best solutions below

3
On

Take two opposite faces of the cube and let's work out the inequality defining what it means to be between those two faces (where the faces have been extended infinitely in all directions).

To make the explanation neat, let's assume the center of the cube is at the origin and the side length of the cube is length 2.

First, work out the normal vector to the faces $\vec{n}$. The dot product $\vec{v} \cdot \vec{n}$ measures the length of the projection of $\vec{v}$ in the direction $\vec{n}$. Being between these faces means the length of that projection is between -1 and 1.

In other words, if $\vec{n} = (a,b,c)$ and $\vec{v} = (x,y,z)$, $$-1 \leq ax+by+cz \leq 1.$$ You can then solve this inequality for $x$ (separate out the cases $x < 0, x = 0,$ and $x > 0$), to get the inequalities on $x$ you're looking for.

Do this for all three pairs of opposite faces and you'll have three inequalities on $x$ (and then $x$ is larger than the maximum of the lower bounds and smaller than the minimum of the upper bounds)

3
On

The box interior can be specified by 6 inequalities, each associated with one plane. For each plane, it is specified by one function (say $f_1(x_1,x_2,x_3) = a_1x_1+a_2x_2+a_3x_3-b = 0$).

Let $R_{v,\theta}$ represent the orthogonal rotation matrix which rotate a point along axis $v=(v_1, v_2, v_3)$ with angle $\theta$. Suppose the rotation matrix map $x$ to $x'$, where $x'=R_{v,\theta}x$. The plane before rotation is $$ \{x: f_1(x) = 0 \}$$

The plane after rotation is

$$ \{x': f_1(R_{v,\theta}^{-1}(x')) = 0\} $$

Therefore, after rotation, the plane is specified by the composite function $f_1 \circ R_{v,\theta}^{-1}$. They are polynomials functions with three spatial variables and degree 1.

Back to the original question. The rotated box interior is specified by 6 inequalities, each looks like $f_1 \circ R_{v,\theta}^{-1} (x) > 0 $.