Quaternions in Python
Carl Banks
idot at vt.edu
Sat Oct 6 11:09:17 EDT 2001
Paul Rubin <phr-n2001 at nightsong.com> wrote:
> Erik Max Francis <max at alcyone.com> writes:
>> > I think there's a simple way to represent quaternions as 3x3 matrices.
>> > So you could probably just store them that way and use NumPy for the
>> > arithmetic.
>>
>> ... which rather defeats the purpose for using quaternions in the first
>> place.
>
> Nah. I mean, if efficiency was a big issue, you wouldn't be using an
> interpreted language in the first place. What's left, if you have a
> good matrix package, is something like if your language had complex
> numbers but didn't have reals. You can still represent the reals as
> complexes. For that matter, lots of languages have had reals but no
> integers. It hasn't been that bad a problem.
You severely underestimate the difficulty of doing this. While any
quarternion can be represented as a 3x3 matrix, not every 3x3 matrix
is a quarternion. And keeping your matrix in "quarternion form" when
you do arithmetic is not trivial.
To wit, a quarternion has 4 components. A 3x3 matrix has 9
components. Therefore, when doing quarternion arithmetic using a 3x3
matrix, you must be sure the resulting matrix satisfies 5 constraints.
And, IIRC, the constraints are not simple.
(Contrast this to using a complex as a real. Here, only one very
simple constraint, namely Im(z)==0, must be maintained.)
--
CARL BANKS
More information about the Python-list
mailing list