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

The CuikSuite Project

defines.h File Reference

#include "error.h"
#include <stdlib.h>
#include <fenv.h>
#include <Clp/Coin_C_defines.h>
#include <float.h>

Go to the source code of this file.

Defines

#define ZERO   1e-11
 Floating point operations giving a value below this constant (in absolute value) are considered 0.
#define INF   COIN_DBL_MAX
#define M_PI   3.14159265358979323846
 Pi.
#define M_PI_2   1.57079632679489661923
 Pi/2.
#define M_2PI   (2.0*M_PI)
 2*Pi.
#define DEG2RAD   (M_PI/180.0)
#define RAD2DEG   (180.0/M_PI)
#define SGN(a)   (a>=0?1:-1)
 Returns the sign of a floating point.
#define ROUNDUP   fesetround(FE_UPWARD)
#define ROUNDDOWN   fesetround(FE_DOWNWARD)
#define ROUNDNEAR   fesetround(FE_TONEAREST)
 Sets the floating point operations in round near mode.
#define NEW(_var, _n, _type)
 Allocates memory space.
#define MEM_EXPAND(_var, _n, _type)
 Expands a previously allocated memory space.
#define MEM_DUP(_var, _n, _type)   {(_n)*=2;MEM_EXPAND(_var,_n,_type);}
 Duplicates a previously allocated memory space.
#define PRINT_VARIABLE_NAME(f, name)   if (name[0]=='_') fprintf(f,"%s",&(name[1])); else fprintf(f,"%s",name)
 Prints a variable name into a file.
#define NO_UINT   ((unsigned int)(-1))

Detailed Description

Definitions of constants and macros used in several parts of the cuik library.

Definition in file defines.h.


Define Documentation

#define ZERO   1e-11

Floating point operations giving a value below this constant (in absolute value) are considered 0.

We use 1e-11 because trigonometric operations (sin/cos/...) give an error typically around 1e-12. Moreover, we print doubles with 12 decimals and, thus the last one typically varies when performing operations. Note that 1e-11 is far below the typical precission used inside the simplex algorithms (1e-6).

No to be confused with parameter EPSILON. ZERO is used as a general threshold to round towards 0 and Epsilon is used only when passing parameters to the simplex. For a super-numerically-stable simplex EPSILON and ZERO would be the same.

Definition at line 36 of file defines.h.

Referenced by AddCt2Monomial(), AddMonomial(), ApplyLinkRot(), BoxSphereClipping(), CmpLinearConstraints(), CropEquation(), CropLinearConstraint(), CSRemoveLCVars(), CtScaleEquation(), EvaluateLinearConstraintInt(), EvaluateMonomialInt(), FixVariableInMonomial(), GetFirstOrderApproximationToEquation(), NewInPatchJoint(), NewRevoluteJoint(), NewUniversalJoint(), NormalizeEquation(), PrintLinearConstraint(), PrintMonomial(), PrintMonomials(), PurgeEquation(), RectangleCircleClipping(), ReplaceVariableInEquation(), ReplaceVariableInMonomial(), SetMonomialCt(), SimplexAddNewConstraint(), and SimplifyLinearConstraint().

#define M_PI   3.14159265358979323846

Pi

Definition at line 59 of file defines.h.

Referenced by IntervalAtan2(), IntervalCosinus(), and NormalizeAngle().

#define M_PI_2   1.57079632679489661923

Pi/2

Definition at line 68 of file defines.h.

Referenced by GenerateSphereOFF(), and IntervalSinus().

#define M_2PI   (2.0*M_PI)
#define DEG2RAD   (M_PI/180.0)

Constant to transform from degrees to radiants.

Definition at line 85 of file defines.h.

Referenced by main().

#define RAD2DEG   (180.0/M_PI)

Constant to transform from radiants to degrees.

Definition at line 91 of file defines.h.

#define SGN (  )     (a>=0?1:-1)

Returns the sign of a floating point: -1 for negative and 1 for possitive or zero.

Definition at line 99 of file defines.h.

#define ROUNDUP   fesetround(FE_UPWARD)
#define NEW ( _var,
_n,
_type   ) 
Value:
{(_var)=(_type *)malloc(sizeof(_type)*(_n)); \
                            if (!(_var)) Error("Memory allocation error");}

Allocates memory space for _n elements of type _type and assigns the pointer to _var. If the memory can not be allocated, triggers and error.

Definition at line 128 of file defines.h.

Referenced by AddBody2Link(), AddConstant(), AddEquation(), AddJoint2Mechanism(), AddLink2Mechanism(), AddMonomial(), AddStepToBranch(), AddVariable(), ApplyLinkRot(), Branch2Link(), ChangeParameter(), ComputeSimpCuikSystemJacobian(), ComputeSplitDimInt(), CopyBox(), CopyBoxSubset(), CopyCPolyhedron(), CopyCuikSystem(), CopyEquation(), CopyEquationInfo(), CopyEquations(), CopyLinearConstraint(), CopyLink(), CopyMapping(), CopyVariable(), CopyVariables(), CopyVarSet(), CopyVector(), CreateFileName(), CropEquation(), CSRemoveLCVars(), CSRemoveVarsWithCtRange(), DeriveEquation(), DeriveVarSet(), DummifyAndAddEquation(), ErrorDueToVariable(), ErrorInInequalities(), ErrorInSolution(), EvaluateEqMin(), GenerateCylinderOFF(), GenerateEquationsFromBranch(), GenerateJointEquations(), GenerateJointEquationsInBranch(), GenerateJointRangeEquations(), GenerateKinTree(), GenerateLinkRot(), GenerateSphereOFF(), GenerateWorldEquationSystems(), GetCSSystemVars(), GetCuikSystemJacobian(), GetFirstOrderApproximationToEquation(), GetTransform2Link(), InitBox(), InitConstants(), InitCPolyhedronFromFile(), InitEquation(), InitEquations(), InitLinearConstraint(), InitLink(), InitMapping(), InitPlot3d(), InitVariables(), InitVarSet(), InitVector(), InitWorldKinCS(), LinearizeCircleEquation(), LinearizeGeneralEquation(), LinearizeParabolaEquation(), LinearizeSaddleEquation(), LinearizeSphereEquation(), ListOfBoxesCluster(), LoadBox(), LoadLinearConstraint(), LoadMapping(), main(), MoveWorld(), MPI_SolveCuikSystem(), MPI_TreatBox(), NewVariable(), PostProcessBox(), PrintCuikSystem(), PrintCuikSystemWithSimplification(), PrintMapping(), PrivAddElement(), ReadBox(), ReadListOfBoxes(), ReadOFF(), RegenerateJointSolution(), SampleCuikSystemInBox(), SaveCSState(), SetEquationInfo(), SetVectorElement(), SimplexAddNewConstraintRaw(), SimplexColEmpty(), SimplexCreate(), SimplexGetColConstraint(), SimplexGetOptimalValue(), SimplexGetOptimizationFunction(), SimplexGetRowConstraint(), SimplexSetOptimizationFunction(), SimplifyCuikSystem(), SplitBox(), SplitGlobalBox(), UpdateCuikSystem(), and UpdateSplitWeight().

#define MEM_EXPAND ( _var,
_n,
_type   ) 
Value:
{(_var)=(_type *)realloc((void *)(_var),sizeof(_type)*(_n)); \
                                   if (!(_var)) Error("Memory reallocation error");}

Expands a previously reserved memory space so that it can accomodate _n elements of type _type assigns the pointer to _var. The previously allocated space is pointed by _var. If the memory can not be expanded, triggers and error.

Definition at line 137 of file defines.h.

Referenced by AddTerm2LinearConstraint(), AddVariableInt(), and SetVectorElement().

#define MEM_DUP ( _var,
_n,
_type   )     {(_n)*=2;MEM_EXPAND(_var,_n,_type);}

Dublicates a previously reserved memory space that accomodates _n elements of type _type. After the duplication, the pointer _var takes to a memory space that can accomodate 2*_n elements and the value of variable _n is also doubled.

Definition at line 147 of file defines.h.

Referenced by AddConstant(), AddEquation(), AddMonomial(), AddTerm2LinearConstraint(), AddVariable(), and AddVariableInt().

#define PRINT_VARIABLE_NAME ( f,
name   )     if (name[0]=='_') fprintf(f,"%s",&(name[1])); else fprintf(f,"%s",name)

Automatically generated variables have a name that starts with a '_'. This is done to avoid the generation of a variable with the same name of a variable defined by the user (the syntax does not allow for variables starting with a '_').
When printing the name of the variable into a file we remove the starting '_' to allow the input parser to read the output file. If this results in a duplicated variable the parser will detect it.

Definition at line 160 of file defines.h.

Referenced by PrintMapping(), PrintVariable(), and PrintVarSet().