Word name completion in listener, and quaternions
Tuesday, October 4, 2005
I added completion popups to the listener. Keyboard selection of possibilities has not been implemented yet. You have to use the mouse.
I also added support for quaternions to Factor’s math library. Quaternions are useful for certain geometrical calculations; a 3-dimensional rotation around an axis can be represented as multiplication by a quaternion.
Quaternions are represented as pairs of real numbers. Literal syntax is
Q{ a b c d }Q
, where a
, b
, c
and d
are real numbers.
Many quaternion operations can be done using Factor’s existing vector algebra words; this follows from the mathematical fact that the quaternions are a 2-dimensional vector space over the complex numbers:
Addition: v+
Subtraction: v-
Negation: vneg
Norm: norm
Multiplication by a complex number on the left: n*v
A few new words are also needed:
Convert complex number to quaternion: c>n
Multiply by a complex number on the right: q*n
Quaternion multiplication: q*
Quaternion division: q/
Quaternion conjugate: qconjugate