This module contains the fundamental types which make working with 3D data much easier. The types are:
You import all of those types at once with
from cgkit.cgtypes import *
or you can import them individually like this
from cgkit.cgtypes import vec3, mat4
In general, you can use those types just as if they were built-in types which means the mathematical operators can be used and have their respective meaning. Each type has some additional methods which are described in the respective documentation.
Here are some examples:
>>> from cgkit.cgtypes import * >>> v=vec3(0.5,1.0,-2.5) >>> print v (0.5000, 1.0000, -2.5000) >>> print v.length() 2.73861278753 >>> v=v.normalize() >>> print v (0.1826, 0.3651, -0.9129) >>> print v.length() 1.0
Now let's construct a rotation matrix that rotates points by 90 degrees around the z-axis:
>>> M=mat4(1).rotate(0.5*math.pi, vec3(0,0,1))
and apply the rotation to the vector (1,0,0) (the x-axis):
>>> print M*vec3(1,0,0) (0.0000, 1.0000, 0.0000)
The module contains the following functions:
| ) |
| eps) |
| t, q0, q1, shortest=True) |
True the interpolation will always
be along the shortest path, otherwise it depends on the orientation of
the input quaternions whether the shortest or longest path will be taken
(you can switch between the paths by negating either q0 or q1).
| t, a, b, c, d) |