Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

htransform.h File Reference

Definition of the THTransform type and the associated functions. More...

#include "defines.h"
#include <stdio.h>

Go to the source code of this file.

Defines

#define DIM_SP   3
 Dimensions of R^3.
#define TX   0
 One of the types of homogeneous transforms in R^3.
#define TY   1
 One of the types of homogeneous transforms in R^3.
#define TZ   2
 One of the types of homogeneous transforms in R^3.
#define RX   3
 One of the types of homogeneous transforms in R^3.
#define RY   4
 One of the types of homogeneous transforms in R^3.
#define RZ   5
 One of the types of homogeneous transforms in R^3.
#define AXIS_X   0
 One of the dimension of R^3.
#define AXIS_Y   1
 One of the dimension of R^3.
#define AXIS_Z   2
 One of the dimension of R^3.
#define AXIS_H   3
 The homogeneous dimension in R^3.

Typedefs

typedef double THTransform [DIM_SP+1][DIM_SP+1]
 A homgeneous transform in R^3.

Functions

void HTransformIdentity (THTransform *t)
 Constructor.
void HTransformCopy (THTransform *t_dst, THTransform *t_org)
 Copy constructor.
void HTransformTx (double tx, THTransform *t)
 Constructor.
void HTransformTy (double ty, THTransform *t)
 Constructor.
void HTransformTz (double tz, THTransform *t)
 Constructor.
void HTransformTxyz (double tx, double ty, double tz, THTransform *t)
 Constructor.
void HTransformRx (double rx, THTransform *t)
 Constructor.
void HTransformRy (double ry, THTransform *t)
 Constructor.
void HTransformRz (double rz, THTransform *t)
 Constructor.
void HTransformRx2 (double s, double c, THTransform *t)
 Constructor.
void HTransformRy2 (double s, double c, THTransform *t)
 Constructor.
void HTransformRz2 (double s, double c, THTransform *t)
 Constructor.
void HTransformCreate (unsigned int dof_r3, double v, THTransform *t)
 Constructor.
void HTransformSetElement (unsigned int i, unsigned int j, double v, THTransform *t)
 Sets an element in a homogeneous transform.
double HTransformGetElement (unsigned int i, unsigned int j, THTransform *t)
 Gets an element in a homogeneous transform.
void HTransformProduct (THTransform *t1, THTransform *t2, THTransform *t3)
 Product of two homogeneous transforms.
void HTransformAdd (THTransform *t1, THTransform *t2, THTransform *t3)
 Addition of two homogeneous transforms.
void HTransformInverse (THTransform *t, THTransform *ti)
 Inverse of a homogeneous transform.
void HTransformOrthonormalize (THTransform *t, THTransform *ta)
 Orthonormalizes the rotation part of a homogenouos transform.
void HTransformX2Vect (double sy, double sz, double *p1, double *p2, THTransform *t)
 Transform a unitary vector along the X axis to a generic vector.
void HTransformTranspose (THTransform *t, THTransform *tt)
 Transpose of a homogeneous transform.
void HTransformAcumTrans (double tx, double ty, double tz, THTransform *t)
 Computes the result of multiplying a homogeneous transform by a translation matrix with parameters tx, ty, tz.
void HTransformAcumTrans2 (THTransform *t_in, double tx, double ty, double tz, THTransform *t)
 Computes the result of multiplying a homogeneous transform by a translation matrix with parameters tx, ty, tz.
void HTransformAcumRot (unsigned int type, double s, double c, THTransform *t)
 Computes the result of multiplying a homogeneous transform by a rotation matrix.
void HTransformAcumRot2 (THTransform *t_in, unsigned int type, double s, double c, THTransform *t)
 Computes the result of multiplying a homogeneous transform by a rotation matrix.
void HTransformApply (double *p_in, double *p_out, THTransform *t)
 Multiply a homogeneous transform and a vector.
void HTransformPrint (FILE *f, THTransform *t)
 Prints the a homogeneous transform to a file.
void HTransformPrintT (FILE *f, THTransform *t)
 Prints the transpose of ahomogeneous transform to a file.
void HTransformDelete (THTransform *t)
 Destructor.

Detailed Description

Module to manage homogeneous transforms in R^3 used to manipulated 3D geometry.

See also:
htransform.c, THTransform, Tplot3d, plot3d.c.

Definition in file htransform.h.


Define Documentation

#define DIM_SP   3

Dimensions of R^3.

See also:
THTransform

Definition at line 27 of file htransform.h.

Referenced by HTransformAdd(), HTransformApply(), HTransformPrint(), HTransformPrintT(), HTransformProduct(), and HTransformTranspose().

#define TX   0

One of the types of homogeneous transforms in R^3: Translation along X.

See also:
THTransform

Definition at line 35 of file htransform.h.

Referenced by HTransformCreate().

#define TY   1

One of the types of homogeneous transforms in R^3: Translation along Y.

See also:
THTransform

Definition at line 43 of file htransform.h.

Referenced by HTransformCreate().

#define TZ   2

One of the types of homogeneous transforms in R^3: Translation along Z.

See also:
Thtransform

Definition at line 51 of file htransform.h.

Referenced by HTransformCreate().

#define RX   3

One of the types of homogeneous transforms in R^3: Rotation about X.

See also:
THTransform

Definition at line 59 of file htransform.h.

Referenced by HTransformAcumRot(), and HTransformCreate().

#define RY   4

One of the types of homogeneous transforms in R^3: Rotation about Y.

See also:
THTransform

Definition at line 67 of file htransform.h.

Referenced by HTransformAcumRot(), and HTransformCreate().

#define RZ   5

One of the types of homogeneous transforms in R^3: Rotation about Z.

See also:
THTransform

Definition at line 75 of file htransform.h.

Referenced by HTransformAcumRot(), and HTransformCreate().

#define AXIS_X   0
#define AXIS_Y   1
#define AXIS_Z   2
#define AXIS_H   3

Typedef Documentation

typedef double THTransform[DIM_SP+1][DIM_SP+1]

A 4x4 matrix representing a homogenous matrix in R^3.

See also:
htransform.h, htransform.c

Definition at line 126 of file htransform.h.


Function Documentation

void HTransformIdentity ( THTransform t  ) 

Initializes a homogeneous transform with the identity matrix.

Parameters:
t The matrix to initialize.

Definition at line 46 of file htransform.c.

References MATRIX_INT_COPY.

Referenced by GetTransform2Link(), HTransformX2Vect(), InitLink(), NewFreeJoint(), NewPrismaticJoint(), NewRevoluteJoint(), NewSphericalJoint(), NewSphSphJoint(), and NewUniversalJoint().

Here is the caller graph for this function:

void HTransformCopy ( THTransform t_dst,
THTransform t_org 
)

Initializes a homogeneous transform from another transform.

Parameters:
t_dst The matrix to initialize.
t_org The matrix from where to copy.

Definition at line 55 of file htransform.c.

References MATRIX_INT_COPY.

Referenced by CopyJoint(), CopyLink(), and NewFixJoint().

Here is the caller graph for this function:

void HTransformTx ( double  tx,
THTransform t 
)

Initializes a homogeneous transform as a translation along X.

Parameters:
tx The displacement along X.
t The matrix to initialize.

Definition at line 65 of file htransform.c.

References AXIS_H, AXIS_X, and MATRIX_INT_COPY.

Referenced by HTransformCreate(), and main().

Here is the caller graph for this function:

void HTransformTy ( double  ty,
THTransform t 
)

Initializes a homogeneous transform as a translation along Y.

Parameters:
ty The displacement along Y.
t The matrix to initialize.

Definition at line 76 of file htransform.c.

References AXIS_H, AXIS_Y, and MATRIX_INT_COPY.

Referenced by HTransformCreate(), and main().

Here is the caller graph for this function:

void HTransformTz ( double  tz,
THTransform t 
)

Initializes a homogeneous transform as a translation along Z.

Parameters:
tz The displacement along Z.
t The matrix to initialize.

Definition at line 87 of file htransform.c.

References AXIS_H, AXIS_Z, and MATRIX_INT_COPY.

Referenced by HTransformCreate(), and main().

Here is the caller graph for this function:

void HTransformTxyz ( double  tx,
double  ty,
double  tz,
THTransform t 
)

Initializes a homogeneous transform as a translation.

Parameters:
tx The displacement along X.
ty The displacement along Y.
tz The displacement along Z.
t The matrix to initialize.

Definition at line 99 of file htransform.c.

References AXIS_H, AXIS_X, AXIS_Y, AXIS_Z, and MATRIX_INT_COPY.

Referenced by GenerateSphereOFF(), and HTransformX2Vect().

Here is the caller graph for this function:

void HTransformRx ( double  rx,
THTransform t 
)

Initializes a homogeneous transform as a rotation about X.

Parameters:
rx The rotation about X in radiants.
t The matrix to initialize.

Definition at line 114 of file htransform.c.

References AXIS_Y, AXIS_Z, and MATRIX_INT_COPY.

Referenced by HTransformCreate(), main(), NewRevoluteJoint(), and NewUniversalJoint().

Here is the caller graph for this function:

void HTransformRy ( double  ry,
THTransform t 
)

Initializes a homogeneous transform as a rotation about Y.

Parameters:
ry The rotation about Y in radiants.
t The matrix to initialize.

Definition at line 131 of file htransform.c.

References AXIS_X, AXIS_Z, and MATRIX_INT_COPY.

Referenced by HTransformCreate(), HTransformX2Vect(), and main().

Here is the caller graph for this function:

void HTransformRz ( double  rz,
THTransform t 
)

Initializes a homogeneous transform as a rotation about Z.

Parameters:
rz The rotation about Z in radiants.
t The matrix to initialize.

Definition at line 148 of file htransform.c.

References AXIS_X, AXIS_Y, and MATRIX_INT_COPY.

Referenced by GenerateSphereOFF(), HTransformCreate(), HTransformX2Vect(), and main().

Here is the caller graph for this function:

void HTransformRx2 ( double  s,
double  c,
THTransform t 
)

Initializes a homogeneous transform as a rotation about X.

Parameters:
s The cosinus of the rotation about X.
c The sinus of the rotation about X.
t The matrix to initialize.

Definition at line 165 of file htransform.c.

References AXIS_Y, AXIS_Z, and MATRIX_INT_COPY.

void HTransformRy2 ( double  s,
double  c,
THTransform t 
)

Initializes a homogeneous transform as a rotation about Y.

Parameters:
s The cosinus of the rotation about Y.
c The sinus of the rotation about Y.
t The matrix to initialize.

Definition at line 175 of file htransform.c.

References AXIS_X, AXIS_Z, and MATRIX_INT_COPY.

void HTransformRz2 ( double  s,
double  c,
THTransform t 
)

Initializes a homogeneous transform as a rotation about Z.

Parameters:
s The cosinus of the rotation about Z.
c The sinus of the rotation about Z.
t The matrix to initialize.

Definition at line 185 of file htransform.c.

References AXIS_X, AXIS_Y, and MATRIX_INT_COPY.

void HTransformCreate ( unsigned int  dof_r3,
double  v,
THTransform t 
)

Initializes a homogeneous transform as translation/rotation in a given degree of freedom.

Parameters:
dof_r3 The degree of freedom: TX, TY, TZ, RX, RY, RZ.
v The translation or rotation (in radiants) for the selected degree of freedom.
t The matrix to initialize.

Definition at line 197 of file htransform.c.

References HTransformRx(), HTransformRy(), HTransformRz(), HTransformTx(), HTransformTy(), HTransformTz(), RX, RY, RZ, TX, TY, and TZ.

Here is the call graph for this function:

void HTransformSetElement ( unsigned int  i,
unsigned int  j,
double  v,
THTransform t 
)

Sets an element in a homogeneous transform. Note that if the element value is not carefully computed the result of using this function could not be an homogeneous matrix anymore (recall that the 3x3 top left sub-matrix must be orthonormal).

Parameters:
i Row of the element to set.
j Column of the element to set.
v The new value for the element
t The matrix to update.

Definition at line 229 of file htransform.c.

References AXIS_H, and Error().

Referenced by ChangeLinkReferenceFrame(), GetTransform2Link(), and HTransformX2Vect().

Here is the call graph for this function:

Here is the caller graph for this function:

double HTransformGetElement ( unsigned int  i,
unsigned int  j,
THTransform t 
)

Gets an element from a homogeneous transform.

Parameters:
i Row of the element to get.
j Column of the element to get.
t The matrix to update.
Returns:
The element at row i column j of homogeneous transform t.

Definition at line 245 of file htransform.c.

References AXIS_H, and Error().

Referenced by GenerateJointEquations(), and NewFixJoint().

Here is the call graph for this function:

Here is the caller graph for this function:

void HTransformProduct ( THTransform t1,
THTransform t2,
THTransform t3 
)

Product of two homogeneous transforms.

Parameters:
t1 The first transform to operate.
t2 The second transform to operate.
t3 The result.

Definition at line 263 of file htransform.c.

References DIM_SP, and MATRIX_INT_COPY.

Referenced by GenerateSphereOFF(), GetTransform2Link(), HTransformInverse(), HTransformX2Vect(), NewRevoluteJoint(), and NewUniversalJoint().

Here is the caller graph for this function:

void HTransformAdd ( THTransform t1,
THTransform t2,
THTransform t3 
)

Addition of two homogeneous transforms.

Parameters:
t1 The first transform to operate.
t2 The second transform to operate.
t3 The result.

Definition at line 292 of file htransform.c.

References DIM_SP, and MATRIX_INT_COPY.

void HTransformInverse ( THTransform t,
THTransform ti 
)

Addition of a homogeneous transform.

Parameters:
t The transform to invert.
ti The result transform with the inverse of the output.

Definition at line 319 of file htransform.c.

References AXIS_H, AXIS_X, AXIS_Y, AXIS_Z, HTransformProduct(), and MATRIX_INT_COPY.

Referenced by NewRevoluteJoint(), and NewUniversalJoint().

Here is the call graph for this function:

Here is the caller graph for this function:

void HTransformOrthonormalize ( THTransform t,
THTransform ta 
)

Orthonormalizes the rotation part of a homogenouos transform.

This is to be used when we have an approximated homogeneous transform (for instance, a homogeneous transform that is derived after several floating point operations). If the rotation part is not orthonormal then the homogeneous transform is no longer a rigid transform (it produces deformations in the objects).

Right now this is implemented in a simple way

  • The first (column) vector of the matrix is normalized.
  • We substract the projectio of the first vector from the second one and we normalize it.
  • The third vector is the cross product of the two first vectors.

An alternative implementation could be based in a SVD of the rotation matrix: after the decomposition the diagonal matrix of (squared) eigenvalues is set to the identity and the matrix is reconstucted. In this way we could avoid the bias of adjusting the matrix from the first column.

Parameters:
t The transform to be orthonormalized
ta The resulting transform with the rotation part orthonormalized.

Definition at line 343 of file htransform.c.

References AXIS_H, and MATRIX_INT_COPY.

Referenced by GetTransform2Link().

Here is the caller graph for this function:

void HTransformX2Vect ( double  sy,
double  sz,
double *  p1,
double *  p2,
THTransform t 
)

Computes the homogeneous matrix that transform a unitary vector along the X axis into a generic vector.

The resulting transform includes, scaling, rotation and translation.

This function is typically used when plotting cylinders. This is the reason to include scale factors in Y and Z (to deform the unitary cylinder along X with radii 1 so that we get the cylinder in the desired position and with the desired witdh, typically the same in Y and Z). The length is controlled by the start-end points of the cilynder.

Parameters:
sy Scale factor to apply in the Y axes.
sz Scale factor to apply in the Z axes.
p1 Initial point of the vector.
p2 Final point of the vector.
t The resulting homogeneous transform.

Definition at line 388 of file htransform.c.

References HTransformIdentity(), HTransformProduct(), HTransformRy(), HTransformRz(), HTransformSetElement(), and HTransformTxyz().

Referenced by GenerateCylinderOFF(), MoveJoint(), NewRevoluteJoint(), NewUniversalJoint(), and PlotCylinder().

Here is the call graph for this function:

Here is the caller graph for this function:

void HTransformTranspose ( THTransform t,
THTransform tt 
)

Transpose of a homogeneous transform. Note that, in general the transpose of a homogeneous transform is not a homogeneous transform.

Parameters:
t The transform to transpose.
tt The result with the transposed matrix.

Definition at line 428 of file htransform.c.

References DIM_SP, and MATRIX_INT_COPY.

void HTransformAcumTrans ( double  tx,
double  ty,
double  tz,
THTransform t 
)

Computes the result of multiplying a homogeneous transform by a translation matrix with parameters tx, ty, tz. The result is accumulated in the given transform.

Parameters:
tx The displacement along X.
ty The displacement along Y.
tz The displacement along Z.
t The matrix where to accumulate the result of the product.
See also:
HTransformAcumTrans2

Definition at line 452 of file htransform.c.

References AXIS_H, AXIS_X, AXIS_Y, and AXIS_Z.

Referenced by HTransformAcumTrans2().

Here is the caller graph for this function:

void HTransformAcumTrans2 ( THTransform t_in,
double  tx,
double  ty,
double  tz,
THTransform t 
)

Computes the result of multiplying a homogeneous transform by a translation matrix with parameters tx, ty, tz. The result is accumulated in the given transform.

Parameters:
t_in The base transform where to accumulate the translation.
tx The displacement along X.
ty The displacement along Y.
tz The displacement along Z.
t The matrix where to store the result.
See also:
HTransformAcumTrans

Definition at line 467 of file htransform.c.

References HTransformAcumTrans(), and MATRIX_INT_COPY.

Here is the call graph for this function:

void HTransformAcumRot ( unsigned int  type,
double  s,
double  c,
THTransform t 
)

Computes the result of multiplying a homogeneous transform by a rotation matrix. The result is accumulated in the given transform.

Parameters:
type Type of rotation to accumulate: RX, RY, RZ.
s sinus of the angle to rotate.
c cosinus of the angle to rotate.
t The matrix from where to depart and where to store the result.
See also:
HTransformAcumRot2

Definition at line 484 of file htransform.c.

References AXIS_H, AXIS_X, AXIS_Y, AXIS_Z, Error(), RX, RY, and RZ.

Referenced by HTransformAcumRot2().

Here is the call graph for this function:

Here is the caller graph for this function:

void HTransformAcumRot2 ( THTransform t_in,
unsigned int  type,
double  s,
double  c,
THTransform t 
)

Computes the result of multiplying a homogeneous transform by a rotation matrix.

Parameters:
t_in The base transform where to accumulate the translation.
type Type of rotation to accumulate: RX, RY, RZ.
s sinus of the angle to rotate.
c cosinus of the angle to rotate.
t The matrix from where to store the result.
See also:
HTransformAcumRot

Definition at line 527 of file htransform.c.

References HTransformAcumRot(), and MATRIX_INT_COPY.

Here is the call graph for this function:

void HTransformApply ( double *  p_in,
double *  p_out,
THTransform t 
)

Multiply a homogeneous transform and a vector.

Parameters:
p_in A input vector in R^3.
p_out The resulting vector in R^3.
t The matrix to apply to the input vector.

Definition at line 539 of file htransform.c.

References AXIS_H, and DIM_SP.

Referenced by ApplyLinkRot(), GenerateCylinderOFF(), GenerateSphereOFF(), MoveJoint(), NewRevoluteJoint(), NewUniversalJoint(), and TransformCPolyhedron().

Here is the caller graph for this function:

void HTransformPrint ( FILE *  f,
THTransform t 
)

Prints the a homogeneous transform to a stream that can be stdtout.

Parameters:
f The file where to print.
t The matrix to print.

Definition at line 560 of file htransform.c.

References DIM_SP.

void HTransformPrintT ( FILE *  f,
THTransform t 
)

Prints the transpose of a homogeneous transform to a stream that can be stdtout. This is implemented because computer graphics community use transposed homogeneous transforms and, consequently, this is how geomview requires the transforms to be printed.

Parameters:
f The file where to print.
t The matrix to print.
See also:
plot3d.h

Definition at line 586 of file htransform.c.

References DIM_SP.

Referenced by Move3dObject(), and PlotCylinder().

Here is the caller graph for this function:

void HTransformDelete ( THTransform t  ) 

Deletes the information stored in the THTransform and frees the allocated memory space.

Parameters:
t The transform to delete.

Definition at line 605 of file htransform.c.

Referenced by DeleteJoint(), DeleteLink(), GenerateCylinderOFF(), GenerateSphereOFF(), main(), MoveJoint(), MoveLink(), NewRevoluteJoint(), NewUniversalJoint(), and PlotCylinder().

Here is the caller graph for this function: