I've a 3D box:
center point = (a,b,c),
width = w,
height = h,
depth = d.
the center point isn't the origin.
I have a ball on the box(touch each other), its
I can rotate the box(around the X axis but its center STAYS the same..) and I want the ball to stay stuck to the box. so the ball needs to be rotated WITH the box.
the angle of the rotation is 45 degrees.
I tried to do this:
I defined the Rotation Matrix around the X axis:
mat 1, 0 , 0 0, cos(45), -sin(45) 0, sin(45), cos(45)
and multiply it by the ball center vector:
(ball.Center().m_x , ball.Center().m_y, ball.Center().m_z) * mat
so I got:
Point3D new_center(ball.Center().m_x, ball.Center().m_y*cos(45) + ball.Center().m_z*sin(45), -(ball.Center().m_y)*sin(45) + ball.Center().m_z*cos(45)); ball.Center() = new_center;
the ball is really rotated when the box is rotated but too far. How can I fix it?