O'Reilly logo

3D Programming for Windows® by Charles Petzold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SLERP and Animation

The RotateTransform3D class defines a property named Rotation that you set to an object of type Rotation3D, which is an abstract class from which both AxisAngleRotation3D and QuaternionRotation3D descend. In previous chapters, I've shown only AxisAngleRotation3D. QuaternionRotation3D has a single property named Quaternion of type Quaternion. In XAML, it looks like this:

<RotateTransform3D>
    <RotateTransform3D.Rotation>
        <QuaternionRotation3D Quaternion="0 0 0.5 0.866" />
    </RotateTransform3D.Rotation>
</RotateTransform3D>

That's a rotation of 60 degrees around the Z axis or (0, 0, 1). The number 0.5 is the sine of half the angle (or 30 degrees), and 0.866 is the cosine of 30 degrees. Remember: In XAML, the w term comes last. You ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required