

As an educational exercise for myself I've created a set of macros to
handle quaternions, which can be useful for rotations. I've compiled
these macros into an include file which I've attached.
Povray thankfully includes the builtin "vaxis_rotate()" function. That,
along with a number of great macros in "transforms.inc", allows you to
handle pretty well all of your "rotational" requirements. So why would
you want to use quaternions to do rotations in Povray? Primarily for
incremental and true angular interpolation rotations. And I've found a
few other uses myself, you might as well.
Quaternions are 4D vectors. Yes, they use complex numbers and are
difficult to understand, but you don't need to preoccupy yourself with
any of this to take advantage of them for 3D rotations. You can think of
a unit (normalized) quaternion as a representation of a rotation. So one
single 4D vector can represent any rotation around any axis. When you
multiply two unit quaternions together, you are effectively adding two
rotations together. Other quaternion tricks are used in these macros
which you may find useful.
If anyone else finds this useful, let me know.
Post a reply to this message
Attachments:
Download 'quaternions.inc.txt' (6 KB)

