POV-Ray : Newsgroups : povray.binaries.scene-files : quaternions.inc : quaternions.inc Server Time
1 Jun 2023 01:03:03 EDT (-0400)
From: None
Date: 6 Oct 2003 13:15:27
Message: <Xns940C86DC9B1D4None@>
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 built-in "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

Download 'quaternions.inc.txt' (6 KB)

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.