From the graphic depicted in this question: Check if a point is inside a rectangular shaped area (3D)?
Points $P_1$ and $P_7$ are known. They are opposite corners of the box. I can obtain Min/Max with $Min(P_1, P_7)$ and $Max(P_1, P_7)$. Although I'm not sure I need the actual min/max as long as both points are opposite.
I have a point $P_A$ between $P_1$ and $P_2$ on a vector $\lvert \vec V_2\rvert$ headed towards $P_2$.
How do I determine points $P_2$, $P_4$, and $P_5$?
What I have done so far:
- Got the center point $P_C$ doing $(P_1$ + $P_7) / 2$.
- Got and X (pitch) and Y (yaw) angles between $P_1$ and $P_A$.
- Translated points $P_1$ and $P_7$ using $P_C$ to be center with origin.
- Rotated the translated points $P_1$ and $P_7$.
- Assuming the box is now axis aligned, computed $P_2$, $P_4$, and $P_5$ locally.
- Rotate and then translate $P_2$, $P_4$, and $P_5$ back.
This seems to work. But it seems a bit cumbersome.
Is there an easier way?
My Goal is to "draw" a Box in 3D space that encompasses a room that is already 3D rendered. I'm working with a scripting language that is layered on top, and it gives very limited access. I can add to the environment and I have access to a Vector object, trig functions (sin/cos/tan/asin/acos/atan), cross product, and dot product. I don't have a Matrix, or other tools often found in graphics frameworks.
The room is sometimes axis aligned, and other times it is rotated from origin 45 degrees. Or a different angle. In this case I'm only dealing with Yaw rotation. In another case I may need to also apply Pitch, for going up or down a staircase. I will never need to apply Roll.