Coordinates
Coordinate systems and their transformations are represented by
the coordinates class.
Instead of 4*4 (homogeneous) matrix representation,
coordinate system in EusLisp is represented by a combination of
a 3*3 rotation matrix and a 3D position vector
mainly for speed and generality.
coordinates [class]
:super propertied-object
:slots (pos :type float-vector
rot :type array)
-
- defines a coordinate system with a pair of a position vector and a 3x3
rotation matrix.
coordinates-p obj [function]
-
-
returns T when obj is an instance of coordinates class or its subclasses.
:rot [method]
-
-
returns the 3X3 rotation matrix of this coords.
:pos [method]
-
-
returns the 3-D position vector of this coords.
:newcoords newrot newpos [method]
-
-
updates the coords with newrot and newpos. Whenever a condition that changes
the state of this coords occurs,
this method should be called with the new rotation
matrix and the position vector.
This message may invoke another :update method to propagate the event.
:replace-coords newrot newpos [method]
-
-
changes the rot and pos slots to be updated without calling newcoords method.
:coords [method]
-
-
:copy-coords &optional dest [method]
-
-
If dest is not given, :copy-coords makes another coordinates object
which has the same rot and pos slots. If dest is given, rot and pos of
this coordinates is copied to the dest coordinates.
:reset-coords [method]
-
-
forces the rotation matrix of this coords to be identity matrix, and pos
vector to be all zero.
:worldpos [method]
-
-
:worldrot [method]
-
-
:worldcoords [method]
-
-
Computes the position vector, the rotation matrix and the coordinates
of this object represented in the world coordinates. The coordinates class
is always assumed to be represented in world, these method can simply return
pos, rot and self. These methods are provided for the compatibility with
cascaded-coords class which cannot be assumed to be represented in world.
:copy-worldcoords &optional dest [method]
-
-
First, worldcoords is computed, and it is copied to dest. If no dest
is specified, a coordinates object to store the result is newly created.
:rotate-vector vec [method]
-
-
A vector is rotated by the rotation of this coords, i.e., an orientation
vector represented in this coords is converted to the representation
in the world.
The position of this coords does not affect rotation.
:transform-vector vec [method]
-
-
A vector in this local coords is transformed to the representation in the world.
:inverse-transform-vector vec [method]
-
-
A vector in the world is inversely transformed to the representation in this
local coordinate system.
:transform trans &optional (wrt :local) [method]
-
-
Transform this coords by the trans represented in wrt coords.
Trans must be of type coordinates, and wrt must be one of keywords
:local, :parent, :world or an instance of coordinates.
If wrt is :local, the trans is applied from the right to this coords,
and if wrt is :world or :parent,
the trans is multiplied from the left.
Else, if wrt is of type coordinates, the trans represented in the wrt
coords is first transformed to the representation in the world, and it
is applied from the left.
:move-to trans &optional (wrt :local) [method]
-
-
Replaces the rot and pos of the coords with trans represented in wrt.
:translate p &optional (wrt :local) [method]
-
-
changes the position of this object
relatively with respective to wrt coords.
:locate p &optional (wrt :local) [method]
-
-
Changes the location of this coords with the parameter represented in wrt.
If wrt is :local, then the effect is identical to
:translate with wrt=:local.
:rotate theta axis &optional (wrt :local) [method]
-
-
Rotates this coords relatively by theta radian around the axis.
Axis is one of axis-keywords (:x, :y and :z) or an arbitrary float-vector.
Axis is considered to be represented in the wrt coords.
Thus, if wrt=:local and axis=:z,
the coordinates is rotated around the z
axis of this local coords, and wrt=:world or :parent,
the coords is rotated around the z axis of world coords.
In other words, if wrt=:local,
a rotation matrix is multiplied from the right of this coords,
and if wrt=:world or :parent,
a rotation matrix is multiplied from the left.
Note that even wrt is either :world or :parent,
the pos vector of this coordinates does not change.
For the true rotation around the world axis,
an instance of coordinates class representing the
rotation should be given to :transform method.
:orient theta axis &optional (wrt :local) [method]
-
-
forces setting rot.
This is an absolute version of :rotate method.
:inverse-transformation [method]
-
-
makes a new coords that is inverse to self.
:transformation coords (wrt :local) [method]
-
-
makes the transformation (an instance of coordinates) between this coords
and the coords given as the argument.
If wrt=:local,
the result is represented in local coords,
i.e., if the resulted transformation is given
as an argument to :transform with wrt=:local,
this coords is transformed
to be identical with the coords.
:Euler az1 ay az2 [method]
-
-
sets rot with Euler angles, that are,
rotation angles around z (az1,
y (ay) and again z az2 axis of
this local coordinates system.
:roll-pitch-yaw roll pitch yaw [method]
-
-
sets rot with roll-pitch-yaw angles:
rotation angles around x (yaw), y (pitch) and z (roll)
axes of the world coordinate system.
:4x4 &optional mat44 [method]
-
-
If a matrix of 4x4 is given as mat44,
it is converted to coordinates representation with a 3x3 rotation matrix and
a 3D position vector.
If mat44 is not given, this coordinates is converted to 4x4
matrix representation.
-
- initializes this coordinates object and sets rot and pos.
The meaning of each keyword follows:
- :dimension
- 2 or 3 (default is 3)
- :pos
- specifies a position vector (defaulted to #f(0 0 0))
- :rot
- specifies a rotation matrix (defaulted to a unit-matrix)
- :Euler
- gives a sequence of three elements for Euler angles
- :rpy
- gives a sequence of three elements for roll-pitch-yaw
- :axis
- rotation axis (:x,:y,:z or an arbitrary float-vector)
- :angle
- rotation angle (used with :axis)
- :wrt
- where the rotation axis is taken (default is :local)
- :4X4
- 4X4 matrix is used to specify both pos and rot
- :coords
- copies pos and rot from coords
- :name
- set :name property
:Angle can only be used in conjunction with the :axis
that is determined in the :wrt coordinates.
Without regard to :wrt, :Euler always specifies
the Euler angles, az1, ay and az2,
defined in the local coordinates,
and :rpy specifies the angles around
z, y and x axes of the world coordinates.
Two or more of :rot, :Euler, :rpy, :axis and :4X4
cannot be specified simultaneously, although no error is reported.
Sequences can be supplied to the :axis and :angle parameters,
which mean successive rotations around the given axes.
List of pairs of an attribute and its value can be given as :properties
argument. These pairs are copied in the plist of this coordinates.
k-okada
2013-05-21