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

The CuikSuite Project

geom.c File Reference

Implementation of the basic geometric functions. More...

#include "geom.h"
#include "error.h"
#include "defines.h"
#include <math.h>
#include <gsl/gsl_linalg.h>

Go to the source code of this file.

Functions

boolean pointLeftOfLine (double px, double py, double x1, double y1, double x2, double y2)
 Determines if a point is at the left of a vector.
boolean pointRightOfLine (double px, double py, double x1, double y1, double x2, double y2)
 Determines if a point is at the right of a vector.
void ComputeBoundingBox (unsigned int n, double *x, double *y, Tinterval *ix, Tinterval *iy)
 Determines the axis aligned bounding box of a set of points in R^2.
void ComputeBoundingBox3d (unsigned int n, double *x, double *y, double *z, Tinterval *ix, Tinterval *iy, Tinterval *iz)
 Determines the axis aligned bounding box of a set of points in R^3.
boolean RectangleCircleClipping (double r2, Tinterval *x, Tinterval *y, Tinterval *x_new, Tinterval *y_new)
 Clips a rectangle and a circle.
boolean BoxSphereClipping (double r2, Tinterval *x, Tinterval *y, Tinterval *z, Tinterval *x_new, Tinterval *y_new, Tinterval *z_new)
 Clips a 3D box and a sphere.
boolean RectangleParabolaClipping (Tinterval *x, double alpha, Tinterval *y, Tinterval *x_new, Tinterval *y_new)
 Clips a 2D box and a scaled parabola.
boolean BoxSaddleClipping (Tinterval *x, Tinterval *y, double alpha, Tinterval *z, Tinterval *x_new, Tinterval *y_new, Tinterval *z_new)
 Clips a 3D box and a scaled saddle.
void DefineNormalVector (double *v, double *n)
 Defines a unitary vector normal to a given vector.
void CrossProduct (double *v1, double *v2, double *v3)
 Computes the cross product of two 3d vectors.
double DotProduct (double *v1, double *v2)
 Computes the dot product of two 3d vectors.
int tolerant_SV_decomp (int M, int N, gsl_matrix *U, gsl_matrix *V, gsl_vector *S)
 Computes the Singular Value Decomposition of a matrix.

Detailed Description

Implementation of the basic geometric functions.

See also:
geom.h.

Definition in file geom.c.


Function Documentation

boolean pointLeftOfLine ( double  px,
double  py,
double  x1,
double  y1,
double  x2,
double  y2 
)

Determines if a 2D point is at the left of a vector in R^2.

Parameters:
px X coordinate of the point.
py Y coordinate of the point.
x1 X coordinate of the first point defining the vector.
y1 Y coordinate of the first point defining the vector.
x2 X coordinate of the second point defining the vector.
y2 Y coordinate of the second point defining the vector.
Returns:
TRUE if point at the left of the vector.
See also:
pointRightOfLine

Definition at line 19 of file geom.c.

References ROUNDDOWN, and ROUNDNEAR.

boolean pointRightOfLine ( double  px,
double  py,
double  x1,
double  y1,
double  x2,
double  y2 
)

Determines if a 2D point is at the right of a vector in R^2.

Parameters:
px X coordinate of the point.
py Y coordinate of the point.
x1 X coordinate of the first point defining the vector.
y1 Y coordinate of the first point defining the vector.
x2 X coordinate of the second point defining the vector.
y2 Y coordinate of the second point defining the vector.
Returns:
TRUE if point at the right of the vector.
See also:
pointLeftOfLine

Definition at line 35 of file geom.c.

References ROUNDNEAR, and ROUNDUP.

void ComputeBoundingBox ( unsigned int  n,
double *  x,
double *  y,
Tinterval ix,
Tinterval iy 
)

Determines the axis aligned bounding box of a set of points in R^2.

Parameters:
n The number of points to be bounded.
x Array with the X coordinates of the points.
y Array with the Y coordinates of the points.
ix Output interval in the X axis.
iy Output interval in the Y axis.

Definition at line 54 of file geom.c.

References NewInterval().

Here is the call graph for this function:

void ComputeBoundingBox3d ( unsigned int  n,
double *  x,
double *  y,
double *  z,
Tinterval ix,
Tinterval iy,
Tinterval iz 
)

Determines the axis aligned bounding box of a set of points in R^3.

Parameters:
n The number of points to be bounded.
x Array with the X coordinates of the points.
y Array with the Y coordinates of the points.
z Array with the Z coordinates of the points.
ix Output interval in the X axis.
iy Output interval in the Y axis.
iz Output interval in the Z axis.

Definition at line 74 of file geom.c.

References NewInterval().

Referenced by NewInPatchJoint().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean RectangleCircleClipping ( double  r2,
Tinterval x,
Tinterval y,
Tinterval x_new,
Tinterval y_new 
)

Reduces the ranges defining a 2D box so that it is adjusted to a zero centered circle with a given radius.

Parameters:
r2 Squared radius of the circle.
x Interval defining the X axis for the 2D box.
y Interval defining the Y axis for the 2D box.
x_new Interval defining the X axis of the box after the clipping.
y_new Interval defining the Y axis of the box after the clipping.
Returns:
TRUE if the intersection is not empty.

Definition at line 102 of file geom.c.

References Intersection(), IntervalAdd(), IntervalInvert(), IntervalPow(), IntervalSqrt(), NewInterval(), Union(), and ZERO.

Referenced by CropEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean BoxSphereClipping ( double  r2,
Tinterval x,
Tinterval y,
Tinterval z,
Tinterval x_new,
Tinterval y_new,
Tinterval z_new 
)

Reduces the ranges defining a 3D box so that it is adjusted to a zero centered sphere with a given radius.

Parameters:
r2 Squared radius of the sphere.
x Interval defining the X axis for the 3D box.
y Interval defining the Y axis for the 3D box.
z Interval defining the Z axis for the 3D box.
x_new Interval defining the X axis of the box after the clipping.
y_new Interval defining the Y axis of the box after the clipping.
z_new Interval defining the Z axis of the box after the clipping.
Returns:
TRUE if the intersection is not empty.

Definition at line 154 of file geom.c.

References Intersection(), IntervalAdd(), IntervalInvert(), IntervalPow(), IntervalSqrt(), NewInterval(), Union(), and ZERO.

Referenced by CropEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean RectangleParabolaClipping ( Tinterval x,
double  alpha,
Tinterval y,
Tinterval x_new,
Tinterval y_new 
)

Reduces the ranges defining a 2D box so that it is adjusted to a scaled parabola, $\alpha y=x^2$.

Parameters:
x Interval defining the X axis for the 2D box.
alpha The scale factor.
y Interval defining the Y axis for the 2D box.
x_new Interval defining the X axis of the box after the clipping.
y_new Interval defining the Y axis of the box after the clipping.
Returns:
TRUE if the intersection is not empty.

Definition at line 224 of file geom.c.

References Intersection(), IntervalInvert(), IntervalPow(), IntervalProduct(), IntervalScale(), IntervalSqrt(), NewInterval(), ROUNDDOWN, ROUNDNEAR, ROUNDUP, and Union().

Referenced by CropEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

boolean BoxSaddleClipping ( Tinterval x,
Tinterval y,
double  alpha,
Tinterval z,
Tinterval x_new,
Tinterval y_new,
Tinterval z_new 
)

Reduces the ranges defining a 3D box so that it is adjusted to scaled saddle equation, $\alpha z=x y$.

Parameters:
x Interval defining the X axis for the 3D box.
y Interval defining the Y axis for the 3D box.
alpha The scale factor.
z Interval defining the Z axis for the 3D box.
x_new Interval defining the X axis of the box after the clipping.
y_new Interval defining the Y axis of the box after the clipping.
z_new Interval defining the Z axis of the box after the clipping.
Returns:
TRUE if the intersection is not empty.

Definition at line 264 of file geom.c.

References CopyInterval(), Intersection(), IntervalDivision(), IntervalProduct(), IntervalScale(), IsInside(), NewInterval(), ROUNDDOWN, ROUNDNEAR, and ROUNDUP.

Referenced by CropEquation().

Here is the call graph for this function:

Here is the caller graph for this function:

void DefineNormalVector ( double *  v,
double *  n 
)

Defines a unitary vector normal to a given vector in R^3. Observe that there is a continous set of normal vectors to a given vector. We just pick one of them.

Parameters:
v The output vector.
n The reference vector.

Definition at line 313 of file geom.c.

References Error().

Here is the call graph for this function:

void CrossProduct ( double *  v1,
double *  v2,
double *  v3 
)

Computes the cross product of two 3d vectors.

Parameters:
v1 First 3d vector.
v2 Second 3d vector.
v3 The output 3d vector.

Definition at line 349 of file geom.c.

Referenced by NewInPatchJoint().

Here is the caller graph for this function:

double DotProduct ( double *  v1,
double *  v2 
)

Computes the dot product of two 3d vectors.

Parameters:
v1 First 3d vector.
v2 Second 3d vector.
Returns:
The dot produt.

Definition at line 362 of file geom.c.

Referenced by NewInPatchJoint().

Here is the caller graph for this function:

int tolerant_SV_decomp ( int  M,
int  N,
gsl_matrix *  U,
gsl_matrix *  V,
gsl_vector *  S 
)

Computes the Singular Value Decomposition A = USV^T of a matrix based on the GSL library.

Parameters:
M Numer of rows of the U matrix.
N Numer of colums of the U matrix.
U Matrix that is decomposed. It is also the U-matrix of the decomposition.
V V-matrix of the decomposition.
S Vector representing the values. of the S Diagonal matrix of the decomposition.
Returns:
0 if no error is encountered in the SVD.

Definition at line 368 of file geom.c.