Graphics Reference
In-Depth Information
Finally, just as before, the meat of the work is done when the mouse moves:
We find the new location of the mouse (in the coordinate system of the controlled
object's parent), build a rotation in that coordinate system, and append this rotation
to the controlled object's initial transformation.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public void mouseMove(System.Windows.Input.MouseEventArgs e)
if (inDrag)
Point3D currPoint = spherePointFromMousePosition(e.GetPosition(viewport3D));
Point3D origin = new Point3D(0, 0, 0);
GeneralTransform3D tt = initialTransform.Inverse;
Vector3D vec1 = tt.Transform(startPoint) - tt.Transform(origin);
Vector3D vec2 = tt.Transform(currPoint) - tt.Transform(origin);
vec1.Normalize();
vec2.Normalize();
double angle = Math.Acos(Vector3D.DotProduct(vec1, vec2));
Vector3D axis = Vector3D.CrossProduct(vec1, vec2);
RotateTransform3D rotateTransform = new RotateTransform3D();
rotateTransform.Rotation = new AxisAngleRotation3D(axis, 180 * angle/Math.PI);
Transform3DGroup tg = new Transform3DGroup();
tg.Children.Add(rotateTransform);
tg.Children.Add(initialTransform);
controlled.Transform = tg;
Before leaving the trackball interface, let's examine some of the design choices
and variants. First, initiating a rotation requires clicking on the object. That in turn
requires moving the pointer so that it appears over the object. Fitts' Law tells us
that this may be a somewhat costly operation if the object is far from the current
pointer location. On the other hand, shifting our attention to the object happens at
the same time, so we can perhaps regard some of the cost as amortized. Having
selected the object with the first click, we then rotate it with a drag, which is
ideal from a Fitts' Law perspective: The drag starts at the most easily accessible
location, the current pointer position. How large a drag is required? That depends
on the radius of the virtual sphere: A rotation of 90 will require a cursor motion
equivalent to the sphere's projected radius. This suggests that a small radius is
ideal. On the other hand, precisely placing the cursor within that small radius can
be difficult; a larger sphere gives the user more precise control of the rotation.
Depending on which is more important for the context, speed or precision, the
designer should adjust the standard interaction-sphere size.
On the mathematical level, we've chosen to work with an integral form of the
interface: The initial point is clicked, and the rotation of that point to the current
point is recomputed for each bit of dragging. As an alternative, we could have used
a differential version, in which the motion from the previous cursor point to the
current one is used to generate a tiny rotation, and these tiny rotations are accu-
mulated by multiplying them into the transform of the object. Unless the cursor
moves along a great circle arc during the drag, the differential and integral forms
give different results. In the differential version, making small circles about the
initial click point generates a spin about that point; making circles in the opposite
direction generates the opposite spin. Users sometimes find this useful. On the
other hand, in the integral form, a drag that ends at the initial point always brings
the object back to its starting orientation, which users may also find useful.
In the differential form, we “accumulate” many small rotations by multiply-
ing them together in the form R 1 R 2 R 3 ...
R k , where k can be quite large. While
each R i may be a rotation matrix within the bounds of numerical precision, their
 
Search WWH ::




Custom Search