Sign in to follow this  
Husbj

Problems with arcball rotation when dragging outside the "ball"

Recommended Posts

Like the title suggests I have implemented arcball rotation (for 3D entities, not cameras by the way) which is simple enough.

I do this by projecting a ray from the mouse coordinates into world space and then doing an intersection test against the virtual sphere ("ball"), storing the initially picked coordinate on the sphere's surface and then generating a quaternion to rotate the sphere such that the initially picked point will end up at the currently projected point. This works as intended, however I would like for the rotation to continue in a natural/smooth manner when the current mouse ray doesn't hit the sphere (of course the initial coordinate is still on the sphere).

At first I thought it would be good enough to just find the closest point on the sphere to the ray, figure out the rotation axis from that and then multiply the angle around it based on the difference between the distance between the "mouse coordinate" and the sphere center, and the radius of the sphere, but that did not work out well at all. I guess this can be attributed to my sadly lacking math skills. Surely there must be ways to achieve this though (you see it every so often in various software after all), but oddly enough I haven't really been able to find any written details of this around the net, so I was wondering if somebody may be willing to point me in the right direction?

Share this post


Link to post
Share on other sites

Thanks, that's a clear improvement!

Still not perfect though, and there's a somewhat significant jump once the cursor goes outside the sphere bounds. May another approach be more suitable?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this