This isn’t really Java dev related, however it is graphics dev related. I’m drawing an axis aligned bounding box and I need to be able to translate it by pitch and roll. I’ve already got yaw working but I’m not sure how to add in the others. Also, this must be without any matrices or quaternions.
Here’s what I have so far, corners array is just the vector positions of the AABB corners (C# but easily understandable):
public void Setup(float yaw, float pitch = 0, float roll = 0)
{
float cosY = (float)Math.Cos(yaw + (float)((Math.PI / 180) * (90)));
float sinY = (float)Math.Sin(yaw + (float)((Math.PI / 180) * (90))); // adding 90 degrees to just rotate the box around a bit to fit better. Not necessary in pitch and roll
for (int i = 0; i < 8; ++i)
{
float x = (corners[i].Z * cosY - corners[i].X * sinY);
float y = (corners[i].X * cosY + corners[i].Z * sinY);
corners[i] = new Vector3D(x, corners[i].Y, y);
corners[i] += origin;
}
}
This works fine to rotate the AABB on the Y axis. How would I add in the x and z axis rotations? Thanks a bunch.