Building simulation of tilt maze - calculating surface height of tilted table

223 Views Asked by At

I'm building a tilt maze game/simulation. A tilt maze is a maze where a user can tilt the surface of a table to move a marble or ball bearing around a maze.

I'm doing this in monogame and it's a right handed coordinate system with Y being the up direction. I calculate the X and Z with newtonian physics but I'm having trouble positioning the height of the sphere so it doesn't float over or go into the table.

The surface of the maze is limited to tilting 10deg in both the X and Z dimensions. This is pretty easy to do in 2D as it's just the sin(rotationAngRadians) * vectorLength. I've tried a number of approaches for 3D and getting nowhere fast.

I have both the X and Z angles for the table and the ball position as a vector. I know that Y=1 is on top of the table when both X and Z angles are 0. If the Z angle rotation is 10 deg (imagine a level playing card to tilting down on the right.), then Y needs to be greater than 1 if X is negative and less than 1 if X is positive.

Here are a couple of jpgs of a tilt maze and a sphere. https://www.dropbox.com/s/wwmfnottzmgynjc/tiltGame1.jpg https://www.dropbox.com/s/6k4unt6hukumyos/tiltGame2.jpg

I have tried creating separate rotation matrixes for X and Z and then multiplying the spherePosition, etc but that's not working correctly.

Anyone have any pointers for what I should read or look at?

Thanks,

Erik

0

There are 0 best solutions below