Bouncing ball in a rotating cube

i want to write a program that shows a ball bouncing in a rotating cube. the cube rotates around the x-axis as well as the y-axis simultaneously. but i’ve no idea how to detect the collision and change the ball speed accordingly after collision. Can anybody offer some help?

There is a tutorial on collision detection at this site.