This used to be on the physics stack exchange but I was told to put it here:
I'm making a game (with physics) and I have a 3D ball rolling down a flat plane. It moves perfectly fine, but the rotation is messed up. It seems way too fast, and the axis seems to be all wrong. Here's the code that runs every tick (20 times per second). (normal
is the normal to the plane, acceleration
is gravity vector projected onto the plane, in m/tick2, and velocity is the velocity in m/tick.)
vec3 rotationAxis = normalize(cross(normal, acceleration));
quat newRotation = rotate(oldRotation, length(velocity) / sphereRadius, rotationAxis); // rotate by v/r radians about the rotationAxis
I'm not sure why this doesn't work, since according to angular mechanics, v=rω and ∆θ=v∆t/r (and ∆t=1 since velocity is in meters/tick). Am I doing something wrong? Why is the rotation so much faster than it should be? And is my axis of rotation correct?
Rephrased in a more physics way, is this correct in 3D:
$$\hat{x} = \frac{\hat{N} \times \vec{a}}{|\hat{N} \times \vec{a}|}$$
$$\Delta \theta \textrm{ about } \hat{x} = \frac{v}{r} \Delta t$$
And if it is correct, then what’s wrong with my code?
rotate(...)
. I'm wondering why the new rotation needs to know about the old rotation. \$\endgroup\$rotate()
be a vector representing the orientation of the ball? \$\endgroup\$