# Convert linear velocity to angular velocity for a ball / sphere (Rolling Ball Maths)

I have a ball moving on a flat plane. I cannot use RigidBody physics, so my object in Kinematic and I am manually handling speed/acceleration. The linear movement of the ball is fine, however as the ball does not rotate, it looks odd.

Given a speed Vector3, where I am moving on the X & Z, I need to figure out how to make the ball "roll".

I think I a running into Euler / Gimbal lock issues by trying this:

transform.Rotate(
180.0f *  speed.z / (Mathf.PI * radius) * dt,
0,
-180.0f * speed.x / (Mathf.PI * radius) * dt
);


This formula is loosely based on the angular velocity formula and converting to degree's per second, with dt (deltaTime).

My gut instinct says that the solution may lie in Quaternions somewehere...?!

Feels like there should be a better way than this?

transform.LookAt(transform.position + speed);
r += 180.0f * speed.magnitude / (Mathf.PI * radius) * dt;
transform.Rotate(Vector3.right, r);


(r is a protected float on the GameObject which I can simply increment to rotate "to" the right angle)

• Note: Turns out this looks rubbish at low speeds. The ball "turns" to face the way it's rolling. That's now how balls work ;) – Nick Nov 28 '16 at 22:46
  Vector3 axis = Vector3.Cross(speed, Vector3.down);
float angle = (speed.magnitude * 360 / circumference);
transform.Rotate(axis, angle * dt, Space.World);


(where speed is a Vector3 and circumference is... well.. the circumference of your ball).

The Cross part gives you the axis on which you need to rotate around. The Space.World part is important too.