link.h File Reference

Detailed Description

Definition of the Tlink type and the associated functions.

See Also
Tlink, link.c.

Definition in file link.h.

Data Structures

struct  Tlink
 Information about each rigid part of a mechanisms. More...
 

Macros

#define ROT_REDUNDANCY   0
 Redundancy in the generated equations. More...
 
#define INIT_NUM_SHAPES   2
 Initial room for shapes in a link. More...
 
#define DLC_R   0.5
 Red component of the default color for links. More...
 
#define DLC_G   0.5
 Green component of the default color for links. More...
 
#define DLC_B   0
 Blue component of the default color for links. More...
 
#define IsGroundLink(id)   (id==0)
 A test that return TRUE if the given identifier is that of the ground link. More...
 

Functions

void InitLink (char *name, Tlink *l)
 Constructor. More...
 
void CopyLink (Tlink *l_dst, Tlink *l_src)
 Copy constructor. More...
 
void AddBody2Link (Tpolyhedron *b, Tlink *l)
 Adds a body to the link. More...
 
void ChangeLinkReferenceFrame (unsigned int r, double **p1, double **p2, Tlink *l)
 Sets a new reference frame for the link. More...
 
unsigned int LinkNBodies (Tlink *l)
 Gets the number of convex parts of the link. More...
 
unsigned int LinkNAtoms (Tlink *l)
 Gets the number of atoms in a link. More...
 
TpolyhedronGetLinkBody (unsigned int i, Tlink *l)
 Gets one of the convex parts of the link. More...
 
unsigned int GetLinkBodyStatus (unsigned int i, Tlink *l)
 Gets the status of one of the convex parts of the link. More...
 
char * GetLinkName (Tlink *l)
 Gets the name of a link. More...
 
boolean IsLinkAllSpheres (Tlink *l)
 Identifies links formed only by spheres. More...
 
void SetPoseVars (Tparameters *p, boolean *vars, TCuikSystem *cs, Tlink *l)
 Identifies the variables giving the pose of the link. More...
 
void SetTransVars (boolean *vars, TCuikSystem *cs, Tlink *l)
 Identifies the variables giving the translation of the link. More...
 
void SetRotVars (Tparameters *p, boolean *vars, TCuikSystem *cs, Tlink *l)
 Identifies the variables giving the rotation of the link. More...
 
void GetLinkPoseSimpVars (Tparameters *p, boolean *sv, TCuikSystem *cs, Tlink *l)
 Identifies the simplified variables giving the rotation of the link. More...
 
void GenerateLinkRot (Tparameters *p, unsigned int lID, TCuikSystem *cs, Tlink *l)
 Generate the variables and constraints related with the rotation of the link reference frame. More...
 
void GenerateLinkRotLinks (Tparameters *p, unsigned int lID, TCuikSystem *cs, Tlink *l)
 Version of GenerateLinkRot for partial matrix representation. More...
 
void GenerateLinkRotFLinks (Tparameters *p, unsigned int lID, TCuikSystem *cs, Tlink *l)
 Version of GenerateLinkRot for full matrix representation. More...
 
void GenerateLinkRotQLinks (Tparameters *p, unsigned int lID, TCuikSystem *cs, Tlink *l)
 Version of GenerateLinkRot for quaternions representation. More...
 
void ApplyLinkRot (Tparameters *pr, double sf, unsigned int sv, double *p, Tequation *eq, TCuikSystem *cs, boolean groundLink, Tlink *l)
 Transforms a vector from the local reference frame to the global one and accumulates the resulting expression into the given equations. More...
 
void ApplyLinkRotVar (Tparameters *pr, double sf, unsigned int *vID, Tequation *eq, TCuikSystem *cs, boolean groundLink, Tlink *l)
 Transforms a variable vector from the local reference frame to the global one and accumulates the resulting expression into the given equations. More...
 
void ApplyLinkRotLinks (double sf, unsigned int sv, double *p, Tequation *eq, TCuikSystem *cs, boolean groundLink, Tlink *l)
 Version of ApplyLinkRot for partial matrix representation. More...
 
void ApplyLinkRotFLinks (double sf, unsigned int sv, double *p, Tequation *eq, TCuikSystem *cs, boolean groundLink, Tlink *l)
 Version of ApplyLinkRot for full matrix representation. More...
 
void ApplyLinkRotQLinks (double sf, unsigned int sv, double *p, Tequation *eq, TCuikSystem *cs, boolean groundLink, Tlink *l)
 Version of ApplyLinkRot for quaternion representation. More...
 
void RegenerateLinkSolution (Tparameters *p, TCuikSystem *cs, double *sol, boolean groundLink, Tlink *l)
 Computes the values for the dummy variables used to represent the rotation matrices for a given link. More...
 
void RegenerateLinkSolutionLinks (TCuikSystem *cs, double *sol, boolean groundLink, Tlink *l)
 Version of RegenerateLinkSolution for partial matrix representation. More...
 
void RegenerateLinkSolutionQLinks (TCuikSystem *cs, double *sol, boolean groundLink, Tlink *l)
 Version of RegenerateLinkSolution for quaternion representation. More...
 
void RegenerateLinkBox (Tparameters *p, TCuikSystem *cs, Tbox *b, boolean groundLink, Tlink *l)
 Computes the values for the dummy variables. More...
 
void RegenerateLinkBoxLinks (TCuikSystem *cs, Tbox *b, boolean groundLink, Tlink *l)
 Version of RegenerateLinkBox for partial matrix representation. More...
 
void RegenerateLinkBoxQLinks (TCuikSystem *cs, Tbox *b, boolean groundLink, Tlink *l)
 Version of RegenerateLinkBox for quaternion representation. More...
 
void GetTransform2Link (Tparameters *p, TCuikSystem *cs, double *sol, boolean groundLink, double *trans, THTransform *t, Tlink *l)
 Gets the homogeneous transform associated with a link for a given solution point. More...
 
void GetTransform2LinkLinks (TCuikSystem *cs, double *sol, boolean groundLink, double *trans, THTransform *t, Tlink *l)
 Version of GetTransform2Link for partial matrix representation. More...
 
void GetTransform2LinkFLinks (TCuikSystem *cs, double *sol, boolean groundLink, double *trans, THTransform *t, Tlink *l)
 Version of GetTransform2Link for full matrix representation. More...
 
void GetTransform2LinkQLinks (TCuikSystem *cs, double *sol, boolean groundLink, double *trans, THTransform *t, Tlink *l)
 Version of GetTransform2Link for quaternion representation. More...
 
void GenerateLinkSolution (Tparameters *p, THTransform *t, TCuikSystem *cs, double *sol, boolean groundLink, Tlink *l)
 Defines the link variables from a transform. More...
 
void GenerateLinkSolutionLinks (THTransform *t, TCuikSystem *cs, double *sol, boolean groundLink, Tlink *l)
 Version of GenerateLinkSolution for partial matrix representation. More...
 
void GenerateLinkSolutionFLinks (THTransform *t, TCuikSystem *cs, double *sol, boolean groundLink, Tlink *l)
 Version of GenerateLinkSolution for full matrix representation. More...
 
void GenerateLinkSolutionQLinks (THTransform *t, TCuikSystem *cs, double *sol, boolean groundLink, Tlink *l)
 Version of GenerateLinkSolution for quaternion representation. More...
 
boolean VisibleLink (Tlink *l)
 Checks if a links has some visible parts. More...
 
double GetLinkMaxCoordinate (Tlink *l)
 Returns the sum of the maximum coordinate value for all the convex polyhedrons in the link. More...
 
void LinkPrintAtoms (FILE *f, THTransform *tl, Tlink *l)
 Prints the center of the atoms in a link in gobal coordinates. More...
 
void LinkStoreAtoms (FILE *f, THTransform *tl, Tlink *l)
 Prints the center of the atoms in a link in gobal coordinates. More...
 
void PlotLink (Tplot3d *pt, double axesLength, Tlink *l)
 Adds a link to a 3d scene. More...
 
void MoveLinkFromTransform (Tplot3d *pt, THTransform *t, Tlink *l)
 Displaces a link in a 3d scene. More...
 
void PrintLink (FILE *f, char *path, char *prefix, Tlink *l)
 Stores the link information into a file. More...
 
void DeleteLink (Tlink *l)
 Destructor. More...
 

Macro Definition Documentation

#define ROT_REDUNDANCY   0

When CT_REPRESENTATION is FLINKS, we can generate some redundant equations regarding the orthonormality of the three coordinates axis. By setting this constant to 0 these redundancy is avoided.

Definition at line 35 of file link.h.

Referenced by GenerateLinkRotFLinks().

#define INIT_NUM_SHAPES   2

Initial room for shapes in a link. Each shape is a convex polyhedron. It will be enlarged if necessary.

See Also
Tlink, Tpolyhedron.

Definition at line 45 of file link.h.

Referenced by CopyLink(), and InitLink().

#define DLC_R   0.5

Red component of the default color for links.

See Also
Tplot3d

Definition at line 53 of file link.h.

#define DLC_G   0.5

Green component of the default color for links.

See Also
Tplot3d

Definition at line 61 of file link.h.

#define DLC_B   0

Blue component of the default color for links.

See Also
Tplot3d

Definition at line 69 of file link.h.

Function Documentation

void InitLink ( char *  name,
Tlink l 
)

Initializes a link structure with no bodies.

Parameters
nameThe name to give to the link.
lThe links to initialize.

Definition at line 69 of file link.c.

References Tlink::allSpheres, Tlink::axisID, Tlink::bodies, Tlink::c, CopyVoidPtr(), Tlink::csvID, DeleteVoidPtr(), HTransformIdentity(), INIT_NUM_SHAPES, InitVector(), Tlink::iR, Tlink::maxCoord, Tlink::name, NEW, NO_UINT, Tlink::nvID, Tlink::R, Tlink::s, TRUE, and Tlink::vID.

Referenced by InitWorldFromMolecule(), and main().

void CopyLink ( Tlink l_dst,
Tlink l_src 
)

Initializes a link copying the information from another link.

Parameters
l_dstThe link to initialize.
l_srcThe link from where to copy.

Definition at line 102 of file link.c.

References AddBody2Link(), Tlink::allSpheres, Tlink::axisID, Tlink::bodies, Tlink::c, CopyVoidPtr(), Tlink::csvID, DeleteVoidPtr(), GetLinkBody(), HTransformCopy(), INIT_NUM_SHAPES, InitVector(), Tlink::iR, LinkNBodies(), Tlink::maxCoord, Tlink::name, NEW, Tlink::nvID, Tlink::R, Tlink::s, TRUE, and Tlink::vID.

Referenced by AddLink2Mechanism().

void AddBody2Link ( Tpolyhedron b,
Tlink l 
)

Adds a body to the link.

Parameters
bThe convex polyhedron to add to the link
lThe link where to add the new polyhedron.

Definition at line 147 of file link.c.

References Tlink::allSpheres, Tlink::bodies, CopyPolyhedron(), DECOR_SHAPE, GetPolyhedronMaxCoordinate(), GetPolyhedronStatus(), GetPolyhedronType(), Tlink::maxCoord, NEW, NewVectorElement(), and SPHERE.

Referenced by AddBody2Mechanism(), CopyLink(), InitWorldFromMolecule(), and main().

void ChangeLinkReferenceFrame ( unsigned int  r,
double **  p1,
double **  p2,
Tlink l 
)

In order to get the simplest possible set of solutions we can select a reference frame for the link different from that used to defined the bodies. This internal reference frame is defined from two (not necessarily orthogonal) vectors. Therefore, we store the sin and cos between the two vectors defining the internal reference frame and the rotation from the frame where bodies are defined and the internal reference frame.

This function does not change the points defining the bodies. (they remain in the original frame), but it changes the way they are interpreted changing the workings of functions GenerateLinkRot and ApplyLinkRot.

If the two given vectors are (almost) aligned, the internal reference frame is not changed.

When using a CT_REPRESENTATION based on quaternions it is not possible to change the internal link reference frame.

Parameters
rThe type of representation to use (i.e., the CT_REPRESENTATION parameter).
p1Two 3d points defining the first vector for the new internal reference frame.
p2Two 3d points defining the second vector for the new internal reference frame.
lThe link whose reference frame we want to change.

Definition at line 163 of file link.c.

References Tlink::c, HTransformSetElement(), Tlink::iR, Tlink::R, REP_JOINTS, REP_QLINKS, and Tlink::s.

Referenced by InitWorldKinCS().

unsigned int LinkNBodies ( Tlink l)

Gets the number of convex parts of the link.

Parameters
lThe link to query.
Returns
The number of convex parts of the link.

Definition at line 246 of file link.c.

References Tlink::bodies, and VectorSize().

Referenced by AddLink2Mechanism(), AddLink2World(), CopyLink(), DeleteLink(), InitPQPCD(), InitSolidCD(), InitVcollideCD(), LinkNAtoms(), LinkPrintAtoms(), LinkStoreAtoms(), MoveLinkFromTransform(), PlotLink(), PrintLink(), VisibleLink(), and WorldAtomJacobian().

unsigned int LinkNAtoms ( Tlink l)

Gets the number of atoms (i.e., spheres) in a link.

Parameters
lThe link to query.
Returns
The number of atoms/spheres in the link.

Definition at line 251 of file link.c.

References GetLinkBody(), GetPolyhedronType(), LinkNBodies(), SPHERE, and VisibleLink().

Referenced by MechanismStoreRigidAtoms().

Tpolyhedron* GetLinkBody ( unsigned int  i,
Tlink l 
)

Gets one of the convex parts of the link.

Parameters
iThe identifier of the convex part to retrive. The identifier of a part is given by the order at which they are added to the link.
lThe link to query.
Returns
A pointer to the requested convex part or NULL if the link does not have any part with the given identifier.

Definition at line 271 of file link.c.

References Tlink::bodies, and GetVectorElement().

Referenced by CopyLink(), DeleteLink(), GetMechanismDefiningPoint(), InitPQPCD(), InitSolidCD(), InitVcollideCD(), LinkNAtoms(), LinkPrintAtoms(), LinkStoreAtoms(), MoveLinkFromTransform(), PlotLink(), PrintLink(), VisibleLink(), and WorldAtomJacobian().

unsigned int GetLinkBodyStatus ( unsigned int  i,
Tlink l 
)

Gets the status of one of the convex parts of the link.

Parameters
iThe identifier of the convex part to query. The identifier of a part is given by the order at which they are added to the link.
lThe link to query.
Returns
The status (NORMAL, HIDDEN, DECOR) of the requested part or NO_UINT if the link does not have any part with the given identifier.

Definition at line 282 of file link.c.

References Tlink::bodies, GetPolyhedronStatus(), GetVectorElement(), and NO_UINT.

Referenced by InitPQPCD(), InitSolidCD(), and InitVcollideCD().

boolean IsLinkAllSpheres ( Tlink l)

Returns TRUE if all non-DECOR bodies in the link (i.e., bodies that are considered in the collision checking) are spheres.

This function is used when generating the collision avoidance related equations. If all involved bodies are spheres we do not use separating planes but we directly bound the squared distance between the sphere centers to be larger than the squared sum of radii.

Parameters
lThe link to query.
Returns
TRUE if all non-DECOR bodies in the link are spheres.

Definition at line 298 of file link.c.

References Tlink::allSpheres.

Referenced by AddBody2Mechanism(), and AddLink2Mechanism().

void SetPoseVars ( Tparameters p,
boolean vars,
TCuikSystem cs,
Tlink l 
)

Sets to TRUE the translations/rotation variables for the given link in the given array of variables.

Parameters
pThe set of parameters.
varsThe array of booleans to set.
csThe cuiksystem where the link variables are included.
lThe link.

Definition at line 303 of file link.c.

References SetRotVars(), and SetTransVars().

void SetTransVars ( boolean vars,
TCuikSystem cs,
Tlink l 
)

Sets to TRUE the translations variables for the given link in the given array of variables. In general the tranlation variables are not in the cuiksystems since translations are computed accumulating displacements over links. The translation variables are only present in very particular cuiksystems and for links that are at the end of a open sequende of links.

Parameters
varsThe array of booleans to set.
csThe cuiksystem where the link variables are included.
lThe link.

Definition at line 309 of file link.c.

References GetCSVariableID(), LINK_TRANS, Tlink::name, NEW, NO_UINT, and TRUE.

Referenced by SetPoseVars().

void SetRotVars ( Tparameters p,
boolean vars,
TCuikSystem cs,
Tlink l 
)

Sets to TRUE the rotation variables for the given link in the given array of variables.

Note that the rotation variables depends on the CT_REPRESENTATION setting.

Parameters
pThe set of parametes.
varsThe array of booleans to set.
csThe cuiksystem where the link variables are included.
lThe link.

Definition at line 442 of file link.c.

References CacheRotVars(), CT_REPRESENTATION, Error(), GetParameter(), NO_UINT, REP_FLINKS, REP_JOINTS, REP_LINKS, REP_QLINKS, TRUE, and Tlink::vID.

Referenced by SetPoseVars().

void GetLinkPoseSimpVars ( Tparameters p,
boolean sv,
TCuikSystem cs,
Tlink l 
)

Identifies variables that give the rotation of the links that survive in the simplified cuiksystem.

Thes variables are identified in an array of booleans and their name is printed to a file (one name per row).

Parameters
pThe set of parameters.
svThe array of booleans to set to TRUE for the good variables.
csThe cuiksystem on which the variable are defined.
lThe link.

Definition at line 478 of file link.c.

References CacheRotVars(), CT_REPRESENTATION, Error(), GetCSVariableName(), GetParameter(), IsSystemVarInSimpCS(), NO_UINT, REP_FLINKS, REP_JOINTS, REP_LINKS, REP_QLINKS, TRUE, and Tlink::vID.

Referenced by GetWorldSimpVariableMask().

void GenerateLinkRot ( Tparameters p,
unsigned int  lID,
TCuikSystem cs,
Tlink l 
)

Each link has a 3D reference frame formed by three vectors (in general orthonormal vectors unless ChangeLinkReferenceFrame is used). This functions add the variales representing the rotation of this reference frame with respect to the gobal reference frame. The translation from this global reference frame to the origin of the frame attached to the link is given by equations involving only rotation variables (and fixed vectors) and can only be computed at the level where we have together links (mechanisms) and cuiksystems, that is, at the world.h level.

Note that the rotation representation depends on the CT_REPRESENTATION setting.

Parameters
pA set of parameters. They include, for instance the dummification level.
lIDThe identifier of the link in the mechanism. Used to generate unique names for the new variables.
csThe cuiksystem where to add the variables and equations.
lThe link from where to generate the variables and equation.

Definition at line 520 of file link.c.

References CT_REPRESENTATION, Error(), GenerateLinkRotFLinks(), GenerateLinkRotLinks(), GenerateLinkRotQLinks(), GetParameter(), REP_FLINKS, REP_JOINTS, REP_LINKS, and REP_QLINKS.

Referenced by InitWorldKinCS().

void GenerateLinkRotLinks ( Tparameters p,
unsigned int  lID,
TCuikSystem cs,
Tlink l 
)

Version of GenerateLinkRot for partial matrix representation.

Parameters
pA set of parameters. They include, for instance the dummification level.
lIDThe identifier of the link in the mechanism. Used to generate unique names for the new variables.
csThe cuiksystem where to add the variables and equations.
lThe link from where to generate the variables and equation.

Definition at line 659 of file link.c.

References AddEquation2CS(), AddVariable2CS(), Tlink::c, DeleteEquation(), DeleteVariable(), DUMMY_VAR, GenerateDotProductEquation(), GenerateNormEquation(), GenerateScaledSaddleEquation(), GetCSVariableID(), IsGroundLink, LINK_ROT2, Tlink::name, NEW, NewInterval(), NewVariable(), NO_UINT, Tlink::s, SetVariableInterval(), and SYSTEM_VAR.

Referenced by GenerateLinkRot().

void GenerateLinkRotFLinks ( Tparameters p,
unsigned int  lID,
TCuikSystem cs,
Tlink l 
)

Version of GenerateLinkRot for full matrix representation.

Parameters
pA set of parameters. They include, for instance the dummification level.
lIDThe identifier of the link in the mechanism. Used to generate unique names for the new variables.
csThe cuiksystem where to add the variables and equations.
lThe link from where to generate the variables and equation.

Definition at line 543 of file link.c.

References AddEquation2CS(), AddVariable2CS(), Tlink::c, DeleteEquation(), DeleteVariable(), GenerateCrossProductEquations(), GenerateDotProductEquation(), GenerateNormEquation(), GetCSVariableID(), IsGroundLink, LINK_ROT, Tlink::name, NEW, NewInterval(), NewVariable(), NO_UINT, ROT_REDUNDANCY, Tlink::s, SetVariableInterval(), and SYSTEM_VAR.

Referenced by GenerateLinkRot().

void GenerateLinkRotQLinks ( Tparameters p,
unsigned int  lID,
TCuikSystem cs,
Tlink l 
)

Version of GenerateLinkRot for quaternion representation.

Parameters
pA set of parameters. They include, for instance the dummification level.
lIDThe identifier of the link in the mechanism. Used to generate unique names for the new variables.
csThe cuiksystem where to add the variables and equations.
lThe link from where to generate the variables and equation.

Definition at line 736 of file link.c.

References AddEquation2CS(), AddMonomial(), AddVariable2CS(), AddVariable2Monomial(), DeleteEquation(), DeleteMonomial(), DeleteVariable(), DUMMY_VAR, EQU, GenerateSaddleEquation(), GetCSVariableID(), InitEquation(), InitMonomial(), IsGroundLink, LINK_ROT3_E, LINK_ROT3_Q, Tlink::name, NEW, NewInterval(), NewVariable(), NFUN, NO_UINT, ResetMonomial(), SetEquationCmp(), SetEquationType(), SetEquationValue(), SetVariableInterval(), SYSTEM_EQ, and SYSTEM_VAR.

Referenced by GenerateLinkRot().

void ApplyLinkRot ( Tparameters pr,
double  sf,
unsigned int  sv,
double *  p,
Tequation eq,
TCuikSystem cs,
boolean  groundLink,
Tlink l 
)

Apply the changes of basis given by the link reference frame to a vector. This results in an expression that transforms the vector from the local reference frame to the global one. These expressions are added to the given equations (one expression for X, another for Y, and another for Z).

Parameters
prThe set of parameters.
sfConstant scale factor to apply to the input vector.
svVariable scale factor given as the identifier of the range in the given box whose center have to be used as scale factor. If no variable scale factor is to be used this parameter should be NO_UINT.
pThe 3D vector in the link reference frame that we want to transform to the global one and to add to trans.
eqSet of 3 equations where to add the 3 expressions resulting from this function (one for the X component of the vector in the globla frame, another for the Y expression and, finally the expression for the Z component).
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers. The numerical identifier of the variable is used to generate a unique name for it.
groundLinkTRUE if the given link is the ground link.
lThe link to use to rotate the given input vector p.

Definition at line 834 of file link.c.

References ApplyLinkRotFLinks(), ApplyLinkRotLinks(), ApplyLinkRotQLinks(), CT_REPRESENTATION, Error(), GetParameter(), REP_FLINKS, REP_JOINTS, REP_LINKS, and REP_QLINKS.

Referenced by ApplyLinkRotVar(), GenerateJointEquations(), GenerateJointEquationsInBranch(), and GenerateJointRangeEquations().

void ApplyLinkRotVar ( Tparameters pr,
double  sf,
unsigned int *  vID,
Tequation eq,
TCuikSystem cs,
boolean  groundLink,
Tlink l 
)

Apply the changes of basis given by the link reference frame to a vector of variables representing a point in local coordinates of the link.

Parameters
prThe set of parameters.
sfConstant scale factor to apply to the input vector.
vIDThe 3D vector of variables to rotate.
eqSet of 3 equations where to add the 3 expressions resulting from this function (one for the X component of the vector in the globla frame, another for the Y expression and, finally the expression for the Z component).
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers. The numerical identifier of the variable is used to generate a unique name for it.
groundLinkTRUE if the given link is the ground link.
lThe link to use to rotate the given input vector p.

Definition at line 1106 of file link.c.

References ApplyLinkRot(), CT_REPRESENTATION, DeleteEquation(), GetParameter(), InitEquation(), NO_UINT, Tlink::R, REP_JOINTS, and VarAccumulateEquations().

void ApplyLinkRotLinks ( double  sf,
unsigned int  sv,
double *  p,
Tequation eq,
TCuikSystem cs,
boolean  groundLink,
Tlink l 
)

Version of ApplyLinkRot for partial matrix representation.

Parameters
sfConstant scale factor to apply to the input vector.
svVariable scale factor given as the identifier of the range in the given box whose center have to be used as scale factor. If no variable scale factor is to be used this parameter should be NO_UINT.
pThe 3D vector in the link reference frame that we want to transform to the global one and to add to trans.
eqSet of 3 equations where to add the 3 expressions resulting from this function (one for the X component of the vector in the globla frame, another for the Y expression and, finally the expression for the Z component).
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers. The numerical identifier of the variable is used to generate a unique name for it.
groundLinkTRUE if the given link is the ground link.
lThe link to use to rotate the given input vector p.

Definition at line 925 of file link.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), Error(), GetCSVariableID(), HTransformApply(), InitMonomial(), LINK_ROT2, Tlink::name, NEW, NFUN, NO_UINT, Tlink::R, ResetMonomial(), and ZERO.

Referenced by ApplyLinkRot().

void ApplyLinkRotFLinks ( double  sf,
unsigned int  sv,
double *  p,
Tequation eq,
TCuikSystem cs,
boolean  groundLink,
Tlink l 
)

Version of ApplyLinkRot for full matrix representation.

Parameters
sfConstant scale factor to apply to the input vector.
svVariable scale factor given as the identifier of the range in the given box whose center have to be used as scale factor. If no variable scale factor is to be used this parameter should be NO_UINT.
pThe 3D vector in the link reference frame that we want to transform to the global one and to add to trans.
eqSet of 3 equations where to add the 3 expressions resulting from this function (one for the X component of the vector in the globla frame, another for the Y expression and, finally the expression for the Z component).
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers. The numerical identifier of the variable is used to generate a unique name for it.
groundLinkTRUE if the given link is the ground link.
lThe link to use to rotate the given input vector p.

Definition at line 859 of file link.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), Error(), GetCSVariableID(), HTransformApply(), InitMonomial(), LINK_ROT, Tlink::name, NEW, NFUN, NO_UINT, Tlink::R, ResetMonomial(), and ZERO.

Referenced by ApplyLinkRot().

void ApplyLinkRotQLinks ( double  sf,
unsigned int  sv,
double *  p,
Tequation eq,
TCuikSystem cs,
boolean  groundLink,
Tlink l 
)

Version of ApplyLinkRot for quaternion representation.

Parameters
sfConstant scale factor to apply to the input vector.
svVariable scale factor given as the identifier of the range in the given box whose center have to be used as scale factor. If no variable scale factor is to be used this parameter should be NO_UINT.
pThe 3D vector in the link reference frame that we want to transform to the global one and to add to trans.
eqSet of 3 equations where to add the 3 expressions resulting from this function (one for the X component of the vector in the globla frame, another for the Y expression and, finally the expression for the Z component).
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers. The numerical identifier of the variable is used to generate a unique name for it.
groundLinkTRUE if the given link is the ground link.
lThe link to use to rotate the given input vector p.

Definition at line 994 of file link.c.

References AddCt2Monomial(), AddMonomial(), AddVariable2Monomial(), DeleteMonomial(), Error(), GetCSVariableID(), InitMonomial(), LINK_ROT3_E, Tlink::name, NEW, NFUN, NO_UINT, ResetMonomial(), and ZERO.

Referenced by ApplyLinkRot().

void RegenerateLinkSolution ( Tparameters p,
TCuikSystem cs,
double *  sol,
boolean  groundLink,
Tlink l 
)

Solution points only include values for the system (and secondary) variables. However, in some formulations, the frame of reference for each link is represented using not only system variables, but dummy variable too. This function computes the values for the link-related dummy variables form the system ones for a given link.

Parameters
pThe set of parameters.
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
solThe solution point with the values for the system variables. At the end of the function, this vector also has values for the link-related dummy variables.
groundLinkTRUE if the given link is the ground link. The rotation matrix for the ground link is fixed (the identity) and, its rotation matrix generates no variables (nor system nor dummy).
lThe link.

Definition at line 1155 of file link.c.

References CT_REPRESENTATION, Error(), GetParameter(), RegenerateLinkSolutionLinks(), RegenerateLinkSolutionQLinks(), REP_FLINKS, REP_JOINTS, REP_LINKS, and REP_QLINKS.

Referenced by RegenerateMechanismSolution().

void RegenerateLinkSolutionLinks ( TCuikSystem cs,
double *  sol,
boolean  groundLink,
Tlink l 
)

Version of RegenerateLinkSolution for partial matrix representation.

Parameters
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
solThe solution point with the values for the system variables. At the end of the function, this vector also has values for the link-related dummy variables.
groundLinkTRUE if the given link is the ground link. The rotation matrix for the ground link is fixed (the identity) and, its rotation matrix generates no variables (nor system nor dummy).
lThe link.

Definition at line 1181 of file link.c.

References CacheRotVarsLinks(), Tlink::s, and Tlink::vID.

Referenced by GenerateLinkSolutionLinks(), and RegenerateLinkSolution().

void RegenerateLinkSolutionQLinks ( TCuikSystem cs,
double *  sol,
boolean  groundLink,
Tlink l 
)

Version of RegenerateLinkSolution for quaternion representation.

Parameters
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
solThe solution point with the values for the system variables. At the end of the function, this vector also has values for the link-related dummy variables.
groundLinkTRUE if the given link is the ground link. The rotation matrix for the ground link is fixed (the identity) and, its rotation matrix generates no variables (nor system nor dummy).
lThe link.

Definition at line 1198 of file link.c.

References CacheRotVarsQLinks(), and Tlink::vID.

Referenced by GenerateLinkSolutionQLinks(), and RegenerateLinkSolution().

void RegenerateLinkBox ( Tparameters p,
TCuikSystem cs,
Tbox b,
boolean  groundLink,
Tlink l 
)

This is the same as RegenerateLinkSolution but working on solution boxes instead of on solution points (i.e. it is interval-based instead of floating point based).

Parameters
pThe set of parameters.
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
bThe solution box with the values for the system variables. At the end of the function, this box also has values for the link-related dummy variables.
groundLinkTRUE if the given link is the ground link. The rotation matrix for the ground link is fixed (the identity) and, its rotation matrix generates no variables (nor system nor dummy).
lThe link.

Definition at line 1222 of file link.c.

References CT_REPRESENTATION, Error(), GetParameter(), RegenerateLinkBoxLinks(), RegenerateLinkBoxQLinks(), REP_FLINKS, REP_JOINTS, REP_LINKS, and REP_QLINKS.

Referenced by RegenerateMechanismBox().

void RegenerateLinkBoxLinks ( TCuikSystem cs,
Tbox b,
boolean  groundLink,
Tlink l 
)

Version of RegenerateLinkBox for partial matrix representation.

Parameters
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
bThe solution box with the values for the system variables. At the end of the function, this box also has values for the link-related dummy variables.
groundLinkTRUE if the given link is the ground link. The rotation matrix for the ground link is fixed (the identity) and, its rotation matrix generates no variables (nor system nor dummy).
lThe link.

Definition at line 1248 of file link.c.

References CacheRotVarsLinks(), GetBoxIntervals(), IntervalProduct(), IntervalScale(), Tlink::s, SetBoxInterval(), and Tlink::vID.

Referenced by RegenerateLinkBox().

void RegenerateLinkBoxQLinks ( TCuikSystem cs,
Tbox b,
boolean  groundLink,
Tlink l 
)

Version of RegenerateLinkBox for quaternion representation.

Parameters
csThe cuik system on which the boxes are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
bThe solution box with the values for the system variables. At the end of the function, this box also has values for the link-related dummy variables.
groundLinkTRUE if the given link is the ground link. The rotation matrix for the ground link is fixed (the identity) and, its rotation matrix generates no variables (nor system nor dummy).
lThe link.

Definition at line 1285 of file link.c.

References CacheRotVarsQLinks(), CopyInterval(), GetBoxInterval(), IntervalProduct(), SetBoxInterval(), and Tlink::vID.

Referenced by RegenerateLinkBox().

void GetTransform2Link ( Tparameters p,
TCuikSystem cs,
double *  sol,
boolean  groundLink,
double *  trans,
THTransform t,
Tlink l 
)

Returns the homogeneous transform with the position and orientation of the link for a given solution point.

Parameters
pThe set of parameters.
csThe cuik system on which the boxes are defined. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
solThe solution point including values for all variables (i.e., already regenerated using RegenerateLinkSolution before calling this function).
groundLinkTRUE if the given link is the ground link.
trans3d vector with the translation from the ground link to this link. The variables for these translations are removed from the cuiksystems and computed from rotations and fixed vectors. Consequently they can only be computed at the level where we have cuiksystems and links (i.e. in world.h)
tThe returned homogeneous transform.
lThe link whose reference frame we want to retrive.

Definition at line 1311 of file link.c.

References CT_REPRESENTATION, Error(), GetParameter(), GetTransform2LinkFLinks(), GetTransform2LinkLinks(), GetTransform2LinkQLinks(), REP_FLINKS, REP_JOINTS, REP_LINKS, and REP_QLINKS.

Referenced by GetLinkTransformsFromSolution(), and PrintJointAxes().

void GetTransform2LinkLinks ( TCuikSystem cs,
double *  sol,
boolean  groundLink,
double *  trans,
THTransform t,
Tlink l 
)

Version of GetTransform2Link for full partial representation.

Parameters
csThe cuik system on which the boxes are defined. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
solThe solution point including values for all variables (i.e., already regenerated using RegenerateLinkSolution before calling this function).
groundLinkTRUE if the given link is the ground link.
trans3d vector with the translation from the ground link to this link. The variables for these translations are removed from the cuiksystems and computed from rotations and fixed vectors. Consequently they can only be computed at the level where we have cuiksystems and links (i.e. in world.h)
tThe returned homogeneous transform.
lThe link whose reference frame we want to retrive.

Definition at line 1372 of file link.c.

References AXIS_H, CacheRotVarsLinks(), HTransformIdentity(), HTransformOrthonormalize(), HTransformProduct(), HTransformSetElement(), Tlink::R, and Tlink::vID.

Referenced by GetTransform2Link().

void GetTransform2LinkFLinks ( TCuikSystem cs,
double *  sol,
boolean  groundLink,
double *  trans,
THTransform t,
Tlink l 
)

Version of GetTransform2Link for full matrix representation.

Parameters
csThe cuik system on which the boxes are defined. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
solThe solution point including values for all variables (i.e., already regenerated using RegenerateLinkSolution before calling this function).
groundLinkTRUE if the given link is the ground link.
trans3d vector with the translation from the ground link to this link. The variables for these translations are removed from the cuiksystems and computed from rotations and fixed vectors. Consequently they can only be computed at the level where we have cuiksystems and links (i.e. in world.h)
tThe returned homogeneous transform.
lThe link whose reference frame we want to retrive.

Definition at line 1335 of file link.c.

References AXIS_H, CacheRotVarsFLinks(), HTransformIdentity(), HTransformOrthonormalize(), HTransformProduct(), HTransformSetElement(), Tlink::R, and Tlink::vID.

Referenced by GetTransform2Link().

void GetTransform2LinkQLinks ( TCuikSystem cs,
double *  sol,
boolean  groundLink,
double *  trans,
THTransform t,
Tlink l 
)

Version of GetTransform2Link for quaternion representation.

Parameters
csThe cuik system on which the boxes are defined. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
solThe solution point including values for all variables (i.e., already regenerated using RegenerateLinkSolution before calling this function).
groundLinkTRUE if the given link is the ground link.
trans3d vector with the translation from the ground link to this link. The variables for these translations are removed from the cuiksystems and computed from rotations and fixed vectors. Consequently they can only be computed at the level where we have cuiksystems and links (i.e. in world.h)
tThe returned homogeneous transform.
lThe link whose reference frame we want to retrive.

Definition at line 1415 of file link.c.

References HTransformIdentity(), HTransformOrthonormalize(), HTransformSetElement(), and Tlink::vID.

Referenced by GetTransform2Link().

void GenerateLinkSolution ( Tparameters p,
THTransform t,
TCuikSystem cs,
double *  sol,
boolean  groundLink,
Tlink l 
)

Generate the solution variables form an homogenous transform giving the pose of the link.

This is basically the reverse of GetTransform2Link.

Parameters
pThe set of parameters.
tThe transform giving the link pose.
csThe cuik system on which the variables are defined.
solThe solution point where to store the generated values.
groundLinkTRUE for the ground link.
lThe link.

Definition at line 1460 of file link.c.

References CT_REPRESENTATION, Error(), GenerateLinkSolutionFLinks(), GenerateLinkSolutionLinks(), GenerateLinkSolutionQLinks(), GetParameter(), REP_FLINKS, REP_JOINTS, REP_LINKS, and REP_QLINKS.

Referenced by WorldDOF2Sol().

void GenerateLinkSolutionLinks ( THTransform t,
TCuikSystem cs,
double *  sol,
boolean  groundLink,
Tlink l 
)

Version of GenerateLinkSolution for partial matrix representation.

Parameters
tThe transform giving the link pose.
csThe cuik system on which the variables are defined.
solThe solution point where to store the generated values.
groundLinkTRUE for the ground link.
lThe link.

Definition at line 1510 of file link.c.

References CacheRotVarsLinks(), HTransformDelete(), HTransformGetElement(), HTransformProduct(), Tlink::iR, RegenerateLinkSolutionLinks(), and Tlink::vID.

Referenced by GenerateLinkSolution().

void GenerateLinkSolutionFLinks ( THTransform t,
TCuikSystem cs,
double *  sol,
boolean  groundLink,
Tlink l 
)

Version of GenerateLinkSolution for full matrix representation.

Parameters
tThe transform giving the link pose.
csThe cuik system on which the variables are defined.
solThe solution point where to store the generated values.
groundLinkTRUE for the ground link.
lThe link.

Definition at line 1484 of file link.c.

References CacheRotVarsFLinks(), HTransformDelete(), HTransformGetElement(), HTransformProduct(), Tlink::iR, and Tlink::vID.

Referenced by GenerateLinkSolution().

void GenerateLinkSolutionQLinks ( THTransform t,
TCuikSystem cs,
double *  sol,
boolean  groundLink,
Tlink l 
)

Version of GenerateLinkSolution for quaternion representation.

Parameters
tThe transform giving the link pose.
csThe cuik system on which the variables are defined.
solThe solution point where to store the generated values.
groundLinkTRUE for the ground link.
lThe link.

Definition at line 1538 of file link.c.

References CacheRotVarsQLinks(), HTransformGetElement(), RegenerateLinkSolutionQLinks(), and Tlink::vID.

Referenced by GenerateLinkSolution().

boolean VisibleLink ( Tlink l)

Checks if a links has some visible parts, i.e., if not all the parts of the link are HIDDEN.

Parameters
lThe link to query.
Returns
TRUE if the link has, at least, one NORMAL of DECOR part.

Definition at line 1564 of file link.c.

References FALSE, GetLinkBody(), GetPolyhedronStatus(), HIDDEN_SHAPE, and LinkNBodies().

Referenced by LinkNAtoms(), LinkPrintAtoms(), LinkStoreAtoms(), MoveLinkFromTransform(), and PlotLink().

double GetLinkMaxCoordinate ( Tlink l)

Returns the sum of the maximum coordinate value (either for X,Y or Z) for all the convex polyhedrons in the link. This is used in higher levels to define an over-estimate bounding-box of the world. This bounding box is used to define the ranges for some of the coordinate and separating planes variables.

Parameters
lThe link to query.
Returns
The sum of the maximum coordinate values for all bodies in the link.

Definition at line 1580 of file link.c.

References Tlink::maxCoord.

Referenced by AddBody2Mechanism(), and AddLink2Mechanism().

void LinkPrintAtoms ( FILE *  f,
THTransform tl,
Tlink l 
)

Stores the centers of the atoms in a given link in global coordinates.

This is used only whent the world represents a molecule and we want to store the atom (i.e., the sphere) positions into a file.

Parameters
fThe file where to store the atom centers.
tlThe transform to get the global coordinates of the link.
lThe link to process.

Definition at line 1624 of file link.c.

References GetLinkBody(), LinkNBodies(), PolyhedronPrintCenter(), and VisibleLink().

Referenced by MechanismPrintAtoms().

void LinkStoreAtoms ( FILE *  f,
THTransform tl,
Tlink l 
)

Stores the centers of the atoms and their radius in a given link in global coordinates.

This is an auxiliary function of MechanismStoreRigidAtoms.

Parameters
fThe file where to store the atom centers.
tlThe transform to get the global coordinates of the link.
lThe link to process.

Definition at line 1641 of file link.c.

References GetLinkBody(), LinkNBodies(), PolyhedronPrintCenterAndCenter(), and VisibleLink().

Referenced by MechanismStoreRigidAtoms().

void PlotLink ( Tplot3d pt,
double  axesLength,
Tlink l 
)

Adds a link to a 3d scene. It adds the diffent parts of the link as if they are expressed in the global frame. To displace the use MoveLinkFromTransform

Parameters
ptThe 3d geometry where to add the link.
axesLength>0 to display the link axes. The value is the length of the lines representing the axes. The reference axes for the link are represeted as red for X, green for Y and blue for Z.
lThe link to add to the scene.

Definition at line 1585 of file link.c.

References Tlink::axisID, Close3dObject(), DeleteColor(), GetLinkBody(), LinkNBodies(), NewColor(), NO_UINT, PlotPolyhedron(), PlotVect3d(), StartNew3dObject(), and VisibleLink().

Referenced by PlotMechanism().

void MoveLinkFromTransform ( Tplot3d pt,
THTransform t,
Tlink l 
)

Displaces a link previously added to a 3d scene from the transform giving the pose of the link.

This function triggers an error (actually the error is triggered in GetTransform2Link) if applied to the groundlink. Note that the groundLink is not suposed to move.

Parameters
ptThe 3d scene where the apply the displacement.
tThe transform giving the pose of the link.
lThe link to move.

Definition at line 1658 of file link.c.

References Tlink::axisID, GetLinkBody(), LinkNBodies(), Move3dObject(), MovePolyhedron(), NO_UINT, and VisibleLink().

Referenced by MoveMechanismFromTransforms().

void PrintLink ( FILE *  f,
char *  path,
char *  prefix,
Tlink l 
)

Stores the link information into a file in the format valid to be read by InitWorldFromFile.

Parameters
fThe file where to store the information.
pathThe working folder.
prefixPrefix to add to the file names for the bodies in this link, if any.
lThe link to print.

Definition at line 1687 of file link.c.

References GetLinkBody(), LinkNBodies(), Tlink::name, NEW, and PrintPolyhedron().

Referenced by PrintMechanism().

void DeleteLink ( Tlink l)

Deletes the information stored in a link and frees the allocated memory.

Parameters
lThe link to delete.

Definition at line 1722 of file link.c.

References Tlink::bodies, Tlink::csvID, DeletePolyhedron(), DeleteVector(), GetLinkBody(), HTransformDelete(), Tlink::iR, LinkNBodies(), Tlink::name, Tlink::nvID, Tlink::R, and Tlink::vID.

Referenced by DeleteMechanism(), InitWorldFromMolecule(), and main().