Klamp't assumes basic familiarity with 3D geometry and linear algebra concepts. It heavily uses structures that representing vectors, matrices, 3D points, 3D rotations, and 3D transformations. These routines are heavily tested and fast.
The main mathematical objects used in Klampt are as follows:
Vector: a variable-length (n-D) vector.Matrix: a variable-size (m x n) matrix.Vector3: a 3-D vector.Matrix3: a 3x3 matrix.Rotation: a 3D rotation, specifically an element of the special orthogonal group SO(3), usually represented by aMatrix3.RigidTransform: a rigid transformationT(x) = R*x + t, withRa rotation andtaVector3
The Klamp't math tutorial is recommended to help better understand how to represent mathematical objects and perform operations on them.
Users should become familiar with the definitions in the following files:
- KrisLibrary/math/math.h contains definitions for basic mathematical routines.
Realis typedef'ed todoubleand (probably) should not be changed. - KrisLibrary/math/vector.h contains a
Vectorclass (typedef'ed toVectorTemplate<Real>). - KrisLibrary/math/matrix.h contains a
Matrixclass (typedef'ed toMatrixTemplate<Real>). - KrisLibrary/math/angle.h contains functions for interpolating and measuring distances of angles on SO(2).
- KrisLibrary/math3d/primitives.h contains 2D and 3D mathematical primitives. The classes
Vector2,Vector3,Matrix2,Matrix3,Matrix4,RigidTransform2DandRigidTransformare efficient implementations of 2D and 3D vector/matrix operations. - KrisLibrary/math3d/rotation contains several representations of rigid 3D rotations, including euler angles, moments (aka exponential maps), angle-axis form, and quaternions. All representations can be transformed into one another. All routines are implemented to be numerically robust.
The Vector, Vector3, and RigidTransform classes are the most widely used math classes in Klamp't. Vectors accept all the basic arithmetic operations as well as dot products, norms, and distances. Applying a transformation (Matrix3 or RigidTransform) to a point (Vector3) is expressed using the * operator.
3D math operations are found in the klampt.math module under the following files.
- vectorops: basic vector operations on lists of numbers.
- so2: routines for handling 2D rotations.
- so3: routines for handling 3D rotations.
- se3: routines for handling 3D rigid transformations
The use of numpy / scipy is recommended if you are doing any significant linear algebra.
