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

The CuikSuite Project

interval.h File Reference

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

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

Go to the source code of this file.

Data Structures

struct  Tinterval
 Defines a interval. More...

Functions

void NewInterval (double lower, double upper, Tinterval *i)
 Constructor.
void CopyInterval (Tinterval *i_dst, Tinterval *i_org)
 Copy constructor.
boolean CmpIntervals (Tinterval *i1, Tinterval *i2)
 Compares two intervals.
double LowerLimit (Tinterval *i)
 Gets the lower limit.
double UpperLimit (Tinterval *i)
 Gets the uppser limit.
double IntervalSize (Tinterval *i)
 Gets the uppser limit.
boolean IsInside (double p, Tinterval *i)
 Checks if a value is inside an interval.
double IntervalCenter (Tinterval *i)
 Gets the interval center.
void SetLowerLimit (double c, Tinterval *i)
 Sets a new lower limit.
void SetUpperLimit (double c, Tinterval *i)
 Sets a new upper limit.
boolean IntervalInclusion (Tinterval *i1, Tinterval *i2)
 Checks is a given interval is fully included into another interval.
boolean Intersect (Tinterval *i1, Tinterval *i2)
 Checks is a two intervals intersect.
boolean Intersection (Tinterval *i1, Tinterval *i2, Tinterval *i_out)
 Computes the intersection of two intervals.
boolean Union (Tinterval *i1, Tinterval *i2, Tinterval *i_out)
 Computes the union of two intervals.
boolean EmptyInterval (Tinterval *i)
 Checks if a given interval is empty.
void IntervalScale (Tinterval *i1, double e, Tinterval *i_out)
 Scales an interval.
void IntervalProduct (Tinterval *i1, Tinterval *i2, Tinterval *i_out)
 Product of two intervals.
void IntervalAdd (Tinterval *i1, Tinterval *i2, Tinterval *i_out)
 Addition of two intervals.
void IntervalSubstract (Tinterval *i1, Tinterval *i2, Tinterval *i_out)
 Substraction of two intervals.
void IntervalInvert (Tinterval *i, Tinterval *i_out)
 Change of sign of a given interval.
void IntervalPow (Tinterval *i, unsigned int p, Tinterval *i_out)
 Power of a given interval by a integer power factor.
boolean IntervalSqrt (Tinterval *i, Tinterval *i_out)
 Interval square root.
void IntervalDivision (Tinterval *num, Tinterval *den, Tinterval *i_out)
 Interval division.
void IntervalOffset (Tinterval *i, double offset, Tinterval *i_out)
 Interval offset.
void IntervalSinus (Tinterval *i, Tinterval *i_out)
 Interval sinus.
void IntervalCosinus (Tinterval *i, Tinterval *i_out)
 Interval cosinus.
void IntervalAtan2 (Tinterval *is, Tinterval *ic, Tinterval *i_out)
 Interval atan2.
void PrintInterval (FILE *f, Tinterval *i)
 Prints an interval.
void DeleteInterval (Tinterval *i)
 Destructor.

Detailed Description

Definition of the Tinterval type and the associated functions.

See also:
Tinterval, interval.c.

Definition in file interval.h.


Function Documentation

void CopyInterval ( Tinterval i_dst,
Tinterval i_org 
)

Defines a new interval from another interval.

Parameters:
i_dst The interval to create.
i_org The interval from where to copy.

Definition at line 59 of file interval.c.

References Tinterval::lower_limit, and Tinterval::upper_limit.

Referenced by BoxSaddleClipping(), CleanLinearConstraint(), CopyBoxSubset(), CopyJoint(), CopyLinearConstraint(), CopyVariable(), CropEquation(), CropLinearConstraint(), GetLinearConstraintError(), NewPrismaticJoint(), NewRevoluteJoint(), NewUniversalJoint(), ReduceRange(), SetBoxInterval(), SetLinearConstraintError(), SetVariableInterval(), SimpleFromOriginal(), and UpdateOriginalFromSimple().

Here is the caller graph for this function:

boolean CmpIntervals ( Tinterval i1,
Tinterval i2 
)

Compares two intervals.

Parameters:
i1 The first interval.
i2 The second interval.
Returns:
TRUE if the two given intervals are the same.

Definition at line 72 of file interval.c.

References Tinterval::lower_limit, and Tinterval::upper_limit.

boolean IsInside ( double  p,
Tinterval i 
)

Checks if a value is inside an interval.

Parameters:
p The value
i The interval.
Returns:
TRUE if the point is inside the interval.

Definition at line 228 of file interval.c.

References Tinterval::lower_limit.

Referenced by AddEquation2Simplex(), BoxSaddleClipping(), CropLinearConstraint(), IntervalPow(), PointInBox(), PointInSubBox(), and PointInSystemBox().

Here is the caller graph for this function:

void SetLowerLimit ( double  c,
Tinterval i 
)

Changes the lower limit for an interval.

Parameters:
c The new lower limit.
i The interval.

Definition at line 134 of file interval.c.

References Tinterval::lower_limit.

Referenced by ReduceRange().

Here is the caller graph for this function:

void SetUpperLimit ( double  c,
Tinterval i 
)

Changes the upper limit for an interval.

Parameters:
c The new lower limit.
i The interval.

Definition at line 139 of file interval.c.

References Tinterval::upper_limit.

Referenced by ReduceRange().

Here is the caller graph for this function:

boolean IntervalInclusion ( Tinterval i1,
Tinterval i2 
)

Checks is a given interval is fully included into another interval.

Parameters:
i1 The interval to be included.
i2 The inclusion interval.
Returns:
TRUE if i1 is fully included in i2.

Definition at line 147 of file interval.c.

References Tinterval::lower_limit, and Tinterval::upper_limit.

Referenced by BoxInclusion().

Here is the caller graph for this function:

boolean Intersect ( Tinterval i1,
Tinterval i2 
)

Checks two given intervals have a non-empty intersection.

Parameters:
i1 The first interval.
i2 The second interval.
Returns:
TRUE if i1 and i2 intersect.

Definition at line 157 of file interval.c.

References Intersection().

Here is the call graph for this function:

boolean Intersection ( Tinterval i1,
Tinterval i2,
Tinterval i_out 
)

Computes the intersection of two intervals.

Parameters:
i1 The first interval.
i2 The second interval.
i_out The output intersection interval, possibly empty.
Returns:
TRUE if i_out is not empty.

Definition at line 170 of file interval.c.

References Tinterval::lower_limit, and Tinterval::upper_limit.

Referenced by BoxesIntersection(), BoxSaddleClipping(), BoxSphereClipping(), CropLinearConstraint(), Intersect(), RectangleCircleClipping(), RectangleParabolaClipping(), SimplifyLinearConstraint(), and UpdateOriginalFromSimple().

Here is the caller graph for this function:

boolean Union ( Tinterval i1,
Tinterval i2,
Tinterval i_out 
)

Computes the union of two intervals.

Parameters:
i1 The first interval.
i2 The second interval.
i_out The output union interval, possibly empty.
Returns:
TRUE if i_out is not empty. The union of two intervals is empty if the two input intervals were empty.

Definition at line 182 of file interval.c.

References FALSE, Tinterval::lower_limit, TRUE, and Tinterval::upper_limit.

Referenced by BoxSphereClipping(), BoxUnion(), RectangleCircleClipping(), and RectangleParabolaClipping().

Here is the caller graph for this function:

boolean EmptyInterval ( Tinterval i  ) 

Checks if a given interval is empty.

Parameters:
i The interval to check.
Returns:
TRUE if i is empty.

Definition at line 220 of file interval.c.

References Tinterval::lower_limit, and Tinterval::upper_limit.

Referenced by PrintInterval(), and ReduceRange().

Here is the caller graph for this function:

void IntervalScale ( Tinterval i1,
double  e,
Tinterval i_out 
)

Product of an interval and a constant.

Parameters:
i1 The input interval.
e The scale factor.
i_out The resulting interval.

Definition at line 237 of file interval.c.

References Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

Referenced by BoxSaddleClipping(), CleanLinearConstraint(), ErrorDueToVariable(), GetFirstOrderApproximationToEquation(), RectangleParabolaClipping(), ScaleBox(), and ScaleLinearConstraint().

Here is the caller graph for this function:

void IntervalProduct ( Tinterval i1,
Tinterval i2,
Tinterval i_out 
)

Product of two intervals.

Parameters:
i1 The first interval.
i2 The second interval.
i_out The resulting interval.

Definition at line 269 of file interval.c.

References Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

Referenced by BoxSaddleClipping(), CropLinearConstraint(), DummifyAndAddEquation(), ErrorDueToVariable(), EvaluateLinearConstraintInt(), EvaluateMonomialInt(), EvaluateVarSetInt(), GetFirstOrderApproximationToEquation(), RectangleParabolaClipping(), SimplexGetOptimalValue(), and SimplifyLinearConstraint().

Here is the caller graph for this function:

void IntervalAdd ( Tinterval i1,
Tinterval i2,
Tinterval i_out 
)

Sum of two intervals.

Parameters:
i1 The first interval.
i2 The second interval.
i_out The resulting interval.

Definition at line 303 of file interval.c.

References Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

Referenced by AddLinearConstraints(), BoxSphereClipping(), CleanLinearConstraint(), CropLinearConstraint(), ErrorDueToVariable(), EvaluateEquationInt(), EvaluateLinearConstraintInt(), GetFirstOrderApproximationToEquation(), NewInPatchJoint(), RectangleCircleClipping(), SimplexGetOptimalValue(), and UpdateOriginalFromSimple().

Here is the caller graph for this function:

void IntervalSubstract ( Tinterval i1,
Tinterval i2,
Tinterval i_out 
)

Substraction of two intervals.

Parameters:
i1 The first interval.
i2 The second interval.
i_out The resulting interval.

Definition at line 322 of file interval.c.

References Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

void IntervalInvert ( Tinterval i,
Tinterval i_out 
)

Change of sign of a given interval. Equivalen to scale the interval with -1.

Parameters:
i The input interval.
i_out The resulting interval.

Definition at line 341 of file interval.c.

References Tinterval::lower_limit, and Tinterval::upper_limit.

Referenced by BoxSphereClipping(), GetFirstOrderApproximationToEquation(), InvertLinearConstraint(), PrintLinearConstraint(), RectangleCircleClipping(), RectangleParabolaClipping(), and UpdateOriginalFromSimple().

Here is the caller graph for this function:

void IntervalPow ( Tinterval i,
unsigned int  p,
Tinterval i_out 
)

Computes

i_out=i_in^p

.

Parameters:
i The input interval.
p The power.
i_out The resulting interval.

Definition at line 352 of file interval.c.

References IsInside(), Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

Referenced by BoxSphereClipping(), DummifyAndAddEquation(), ErrorDueToVariable(), EvaluateVarSetInt(), GetFirstOrderApproximationToEquation(), NewInPatchJoint(), RectangleCircleClipping(), and RectangleParabolaClipping().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean IntervalSqrt ( Tinterval i,
Tinterval i_out 
)

Computes the square root of an interval. Negative parts of the interval are not taken into account. If the whole input interval is negative the result is an empty interval.

Parameters:
i The input interval.
i_out The resulting interval.
Returns:
TRUE if the output interval is NULL.

Definition at line 386 of file interval.c.

References FALSE, Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, TRUE, and Tinterval::upper_limit.

Referenced by BoxSphereClipping(), NewInPatchJoint(), RectangleCircleClipping(), and RectangleParabolaClipping().

Here is the caller graph for this function:

void IntervalDivision ( Tinterval num,
Tinterval den,
Tinterval i_out 
)

Divides one interval by another. If the denominator includes the zero, this function triggers an error.

Parameters:
num The interval numerator.
den The interval denominator.
i_out The resulting interval.

Definition at line 412 of file interval.c.

References Error(), Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

Referenced by BoxSaddleClipping(), CropLinearConstraint(), and SimplifyLinearConstraint().

Here is the call graph for this function:

Here is the caller graph for this function:

void IntervalOffset ( Tinterval i,
double  offset,
Tinterval i_out 
)

Displaces an interval by a constant value.

Parameters:
i The input interval.
offset The quantity to add to the interval limits.
i_out The resulting interval.

Definition at line 448 of file interval.c.

References Tinterval::lower_limit, ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

Referenced by AddCt2LinearConstraint(), AddEquation2Simplex(), ErrorDueToVariable(), EvaluateEqMin(), GetFirstOrderApproximationToEquation(), NewRevoluteJoint(), and NewUniversalJoint().

Here is the caller graph for this function:

void IntervalSinus ( Tinterval i,
Tinterval i_out 
)

Computes the bound of the sinus on a given interval.

Parameters:
i The input interval.
i_out The resulting interval.

Definition at line 468 of file interval.c.

References IntervalSinus(), IntervalSize(), Tinterval::lower_limit, M_2PI, M_PI_2, NewInterval(), NormalizeAngle(), ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Tinterval::upper_limit.

Referenced by IntervalSinus().

Here is the call graph for this function:

Here is the caller graph for this function:

void IntervalCosinus ( Tinterval i,
Tinterval i_out 
)

Computes the bound of the cosinus on a given interval.

Parameters:
i The input interval.
i_out The resulting interval.

Definition at line 528 of file interval.c.

References IntervalCosinus(), IntervalSize(), Tinterval::lower_limit, M_2PI, M_PI, NewInterval(), NormalizeAngle(), and Tinterval::upper_limit.

Referenced by GenerateJointRangeEquations(), and IntervalCosinus().

Here is the call graph for this function:

Here is the caller graph for this function:

void IntervalAtan2 ( Tinterval is,
Tinterval ic,
Tinterval i_out 
)

Computes the bound of the atan2 on a given sin/cos intervals.

The current implementation is tailored to post-process solution files and in only works for small intervals.

The output in in the range $[-\pi,\pi]$ except for the case where is and ic include (-1,0). In this case the output interval is in the range $[0,2\:\pi]$.

Parameters:
is The sinus interval.
ic The cosinus interval.
i_out The resulting interval.

Definition at line 578 of file interval.c.

References Error(), IntervalSize(), Tinterval::lower_limit, M_2PI, M_PI, and Tinterval::upper_limit.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintInterval ( FILE *  f,
Tinterval i 
)

Writes an interval to a stream that can be stdout.

Parameters:
f The strem.
i The interval to write.

Definition at line 616 of file interval.c.

References EmptyInterval(), INF, Tinterval::lower_limit, and Tinterval::upper_limit.

Referenced by AddEquation2Simplex(), CropEquation(), PrintBox(), PrintBoxSubset(), PrintLinearConstraint(), PrintVariable(), ReduceRange(), SetSimplexBounds(), and SimplexAddNewConstraintRaw().

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteInterval ( Tinterval i  ) 

Deletes an interval structure.

Parameters:
i The interval to delete.

Definition at line 637 of file interval.c.

Referenced by DeleteJoint(), DeleteLinearConstraint(), GenerateEquationsFromBranch(), GenerateJointEquations(), GenerateJointRangeEquations(), and main().

Here is the caller graph for this function: