OpenGLContext.quaternion
index
p:\openglcontext\quaternion.py

Simple module providing a quaternion class for manipulating rotations easily.
 
Note: all angles are assumed to be specified in radians.
Note: this is an entirely separate implementation from the PyOpenGL
        quaternion class.  This implementation assumes that Numeric python
        will be available, and provides only those methods and helpers
        commonly needed for manipulating rotations.

 
Modules
            
copy
copy_reg
math
multiarray
pickle
string
types
OpenGLContext.utilities
 
Classes
            
object
Quaternion
 
class Quaternion(object)
      Quaternion object implementing those methods required
to be useful for OpenGL rendering (and not many others)
 
   Methods defined here:
XYZR(self)
Get a VRML-style axis plus rotation form of the rotation.
Note that this is in radians, not degrees, and that the angle
is the last, not the first item... (x,y,z,radians)
__getitem__(self, x)
__init__(self, elements=[1, 0, 0, 0])
The initializer is a four-element array,
 
w, x,y,z -- all elements should be doubles/floats
the default values are those for a unit multiplication
quaternion.
__len__(self)
__mul__(self, other)
Multiply this quaternion by another quaternion,
generating a new quaternion which is the combination of the
rotations represented by the two source quaternions.
 
Other is interpreted as taking place within the coordinate
space defined by this quaternion.
 
Alternately, if "other" is a matrix, return the dot-product
of that matrix with our matrix (i.e. rotate the coordinate)
__repr__(self)
Return a human-friendly representation of the quaternion
 
Currently this representation is as an axis plus rotation (in radians)
delta(self, other)
Return the angle in radians between this quaternion and another.
 
Return value is a positive angle in the range 0-pi representing
the minimum angle between the two quaternion rotations.
 
From code by Halldor Fannar on the 3D game development algos list
matrix(self)
Get a rotation matrix representing this rotation
slerp(self, other, fraction=0, minimalStep=0.0001)
Perform fraction of spherical linear interpolation from this quaternion to other quaternion
 
Algo is from: http://www.gamasutra.com/features/19980703/quaternions_01.htm

Data and non-method functions defined here:
__doc__ = 'Quaternion object implementing those methods req...useful for OpenGL rendering (and not many others)'
__getstate__ = <built-in function __getstate__>
__module__ = 'OpenGLContext.quaternion'
__slots__ = ('internal', '__weakref__')
__weakref__ = <member '__weakref__' of 'Quaternion' objects>
internal = <member 'internal' of 'Quaternion' objects>

Methods inherited from object:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__hash__(...)
x.__hash__() <==> hash(x)
__reduce__(...)
helper for pickle
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__str__(...)
x.__str__() <==> str(x)

Data and non-method functions inherited from object:
__class__ = <type 'type'>
__new__ = <built-in method __new__ of type object at 0x1E0BD978>
T.__new__(S, ...) -> a new object with type S, a subtype of T
 
Functions
            
fromEuler(x=0, y=0, z=0)
Create a new quaternion from a 3-element euler-angle
rotation about x, then y, then z
fromXYZR(x, y, z, r)
Create a new quaternion from a VRML-style rotation
x,y,z are the axis of rotation
r is the rotation in radians.
test()