Virtual trackball and mouse pos out of the sphere

Hi All,

We noticed that some popular 3D app can smoothly rotate the model even with the mouse out of the virtual trackball sphere (instead of spinning the model around the Z axis coming out of the screen as we all do)

What is the trick behind this?

As you know when the mouse pointer is out of the sphere one of the vector components is zero and the cross product always gives a rotation axis perpendicular to the screen surface.

Thanks in advance,


Turntable versus trackball ?

Hi Zbuffer,

We have tryed both, but what I see is something still different.

I will prepare a movie to show you what I mean.



Here are the movies:

  1. Turntable (hor mouse movements in rotation around the vertical axis and ver mouse movements in rotation around world X axis)
    Turntable movie

  2. “Smart” trackball - want we would like to achieve - (inside the sphere we know outside we don’t)
    Smart trackball movie

Do you notice how smoothly the mouse move far in the viewport corner withot making the model to spin?

Please let me know what you think.


I wanted also to add - for a better understanding - that the product I used to make movies, calls

Turntable: rotate around world axes

Trackball: rotate relative to view

In effect we managed to mimic the “Smart trackball” using the turtable approach on camera up and right axis, but unfortunately the model is not stick at the mouse cursor as in the movie provided.



looks like the virtual trackball sphere is scaled up to the mouse pointer when the mouse pointer is outside the default sphere.

Think about it, scaling the trackball would simply keep the mouse position on the sphere edge (circle) always producing a rotation axis perpendicular to the screen.

We also tried to:

  1. switch to turntable when outside of the spere but it doesn’t look fine
  2. use a trackball diameter equal to the viewport diagonal, again with no luck

There is something more that we miss.

Thaks again,


Hey guys, any other good idea on this trick?



Sure, here’s a random idea. The idea with trackball rotation is you project the sphere to a plane, and then the mouse selects a point on the plane (which corresponds to a point on the sphere), moves it to another point on the plane, and computes the corresponding rotation that maps the first point to the second.

To be able to rotate more than just a hemisphere (all that’s visible in the projection from sphere to plane), try a different projection. E.g. Paul Debevec has a full sphere mapping onto a plane for his lightprobe images - he details the math of the projection on . If you take your two points on the plane to be points according to this mapping, then you could rotate past the normal hemisphere of trackball rotation.

Hi Stephen,

I don’t follow your explanation and I find it difficult also to find a program to downlaod to test this trackball approach.

Please help me further.



It was just a random idea. There’s plenty of research on this topic in the 3D UI literature. Check out the paper “Virtual Trackballs Revisited”. The authors have code up here: As described in that paper, you probably want a Bell trackball.

Nice link,

I’ll take a look to this article and let you know.



It looks like the virtual trackball you want is Andy Hanson’s rolling ball" technique. He calls it context free, since you get the same rotation regardless of whether you’re in the sphere or not. It does rotation in the x-y plane, but not around z except via a weird side effect that you can read about – see below).

The technique is described in Graphics Gems III, though the code given is pretty much just an outline. A more thorough explanation can be found in Gems V and in his new book “Visualizing Quaternions”.

A working implementation can be found at:


Yes, rolling ball is another intersting approach I will read more about it.

BTW it is not what you see in the movie provided.


Hi Alberto,

I’m currently studying the differences between the most popular virtual trackball algorithms (Chen, Hanson, Shoemake and Bell). So I am very interested in this topic. The only difference I see between your smart trackball movie and Hanson’s rolling ball is that the movie doesn’t show the precession in Hanson’s algorithm (where small rotations cause the entire ball to rotate around the z-axis in the opposite direction).

Could you tell me what other difference(s) you see?



In my opinion the difference is that when the mouse is over the sphere (diameter of the smallest viewport dim) it works like the Shoemake one while out side it work like a rolling ball.

It is quite difficult to merge the two smoothly.