POV-Ray : Newsgroups : povray.binaries.scene-files : quaternions.inc : quaternions.inc Server Time 1 Jun 2023 01:03:03 EDT (-0400)
 quaternions.inc
 From: None Date: 6 Oct 2003 13:15:27 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#Xns940C86DC9B1D4None%40204.213.191.226",
"dateCreated": "2003-10-06T17:15:27+00:00",
"datePublished": "2003-10-06T17:15:27+00:00",
"author": {
"@type": "Person",
"name": "None"
}
}
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.
```

Attachments: