WTFIT
Public Member Functions | Static Public Member Functions | List of all members
wtfit::Geometry Class Reference

Minimalist class that handles simple geometric computations (operations on vectors, barycentric coordinates, etc.). More...

#include <Geometry.h>

Inheritance diagram for wtfit::Geometry:
wtfit::Debug

Public Member Functions

 Geometry ()
 
virtual ~Geometry ()
 
- Public Member Functions inherited from wtfit::Debug
 Debug ()
 
virtual ~Debug ()
 
virtual const int dMsg (ostream &stream, string msg, const int &debugLevel=infoMsg) const
 
const int err (const string msg, const int &debugLevel=infoMsg) const
 
const int msg (const char *msg, const int &debugLevel=infoMsg) const
 
virtual const int setDebugLevel (const int &debugLevel)
 
int setThreadNumber (const int threadNumber)
 
int setWrapper (const Wrapper *wrapper)
 

Static Public Member Functions

static double angle (const double *vA0, const double *vA1, const double *vB0, const double *vB1)
 
static bool areVectorsColinear (const double *vA0, const double *vA1, const double *vB0, const double *vB1, vector< double > *coefficients=NULL, const double *tolerance=NULL)
 
static int computeBarycentricCoordinates (const double *p0, const double *p1, const double *p, vector< double > &baryCentrics, const int &dimension=3)
 
static int computeBarycentricCoordinates (const double &x0, const double &y0, const double &x1, const double &y1, const double &x, const double &y, vector< double > &baryCentrics)
 
static int computeBarycentricCoordinates (const double *p0, const double *p1, const double *p2, const double *p, vector< double > &baryCentrics)
 
static int computeBarycentricCoordinates (const float *p0, const float *p1, const float *p2, const float *p, vector< double > &baryCentrics)
 
static bool computeSegmentIntersection (const double &xA, const double &yA, const double &xB, const double &yB, const double &xC, const double &yC, const double &xD, const double &yD, double &x, double &y)
 
static int computeTriangleAngles (const double *p0, const double *p1, const double *p2, vector< double > &angles)
 
static int computeTriangleArea (const double *p0, const double *p1, const double *p2, double &area)
 
static int crossProduct (const double *vA0, const double *vA1, const double *vB0, const double *vB1, vector< double > &crossProduct)
 
static int crossProduct (const double *vA, const double *vB, double *vC)
 
static double distance (const double *p0, const double *p1, const int &dimension=3)
 
static double distance (const float *p0, const float *p1, const int &dimension=3)
 
static double dotProduct (const double *vA0, const double *vA1, const double *vB0, const double *vB1)
 
static double dotProduct (const double *vA, const double *vB)
 
static int getBoundingBox (const vector< vector< double > > &points, vector< pair< double, double >> &bBox)
 
static bool isPointInTriangle (const double *p0, const double *p1, const double *p2, const double *p)
 
static bool isPointInTriangle (const float *p0, const float *p1, const float *p2, const float *p)
 
static bool isPointOnSegment (const double &x, const double &y, const double &xA, const double &yA, const double &xB, const double &yB)
 
static bool isPointOnSegment (const double *p, const double *pA, const double *pB, const int &dimension=3)
 
static bool isTriangleColinear (const double *p0, const double *p1, const double *p2, const double *tolerance=NULL)
 
static double magnitude (const double *v)
 
static double magnitude (const double *o, const double *d)
 

Additional Inherited Members

- Public Types inherited from wtfit::Debug
enum  debugPriority {
  fatalMsg, timeMsg, memoryMsg, infoMsg,
  detailedInfoMsg, advancedInfoMsg
}
 
- Protected Attributes inherited from wtfit::Debug
bool lastObject_
 
int debugLevel_
 
int threadNumber_
 
Wrapperwrapper_
 

Detailed Description

Minimalist class that handles simple geometric computations (operations on vectors, barycentric coordinates, etc.).

Author
Julien Tierny julie.nosp@m.n.ti.nosp@m.erny@.nosp@m.lip6.nosp@m..fr
Date
February 2016.

Constructor & Destructor Documentation

Geometry::Geometry ( )
Geometry::~Geometry ( )
virtual

Member Function Documentation

double Geometry::angle ( const double *  vA0,
const double *  vA1,
const double *  vB0,
const double *  vB1 
)
static

Compute the angle between two vectors

Parameters
vA0xyz coordinates of vA's origin
vA1xyz coordinates of vA's destination
vB0xyz coordinates of vB's origin
vB1xyz coordinates of vB's destination
bool Geometry::areVectorsColinear ( const double *  vA0,
const double *  vA1,
const double *  vB0,
const double *  vB1,
vector< double > *  coefficients = NULL,
const double *  tolerance = NULL 
)
static

Check if two 3D vectors vA and vB are colinear.

Parameters
vA0xyz coordinates of vA's origin
vA1xyz coordinates of vA's destination
vB0xyz coordinates of vB's origin
vB1xyz coordinates of vB's destination
coefficientsOptional output vector of colinearity coefficients.
Returns
Returns true if the vectors are colinear, false otherwise.
int Geometry::computeBarycentricCoordinates ( const double *  p0,
const double *  p1,
const double *  p,
vector< double > &  baryCentrics,
const int &  dimension = 3 
)
static

Compute the barycentric coordinates of point p with regard to the edge defined by the 3D points p0 and p1.

Parameters
p0xyz coordinates of the first vertex of the edge
p1xyz coordinates of the second vertex of the edge
pxyz coordinates of the queried point
baryCentricsOutput barycentric coordinates (all in [0, 1] if p belongs to the edge).
dimensionOptional parameter that specifies the dimension of the point set (by default 3).
Returns
Returns 0 upon success, negative values otherwise.
static int wtfit::Geometry::computeBarycentricCoordinates ( const double &  x0,
const double &  y0,
const double &  x1,
const double &  y1,
const double &  x,
const double &  y,
vector< double > &  baryCentrics 
)
static

Compute the barycentric coordinates of point xyz with regard to the edge defined by the points xy0 and xy1.

Parameters
x0x coordinate of the first vertex of the edge
y0y coordinate of the first vertex of the edge
x1x coordinate of the second vertex of the edge
y1y coordinate of the second vertex of the edge
xx coordinate of the queried point
yy coordinate of the queried point
baryCentricsOutput barycentric coordinates (all in [0, 1] if p belongs to the edge).
Returns
Returns 0 upon success, negative values otherwise.
int Geometry::computeBarycentricCoordinates ( const double *  p0,
const double *  p1,
const double *  p2,
const double *  p,
vector< double > &  baryCentrics 
)
static

Compute the barycentric coordinates of point p with regard to the triangle defined by the 3D points p0, p1, and p2.

Parameters
p0xyz coordinates of the first vertex of the triangle
p1xyz coordinates of the second vertex of the triangle
p2xyz coordinates of the third vertex of the triangle
pxyz coordinates of the queried point
baryCentricsOutput barycentric coordinates (all in [0, 1] if p belongs to the triangle).
Returns
Returns 0 upon success, negative values otherwise.
int Geometry::computeBarycentricCoordinates ( const float *  p0,
const float *  p1,
const float *  p2,
const float *  p,
vector< double > &  baryCentrics 
)
static

Compute the barycentric coordinates of point p with regard to the triangle defined by the points p0, p1, and p2.

Parameters
p0xyz coordinates of the first vertex of the triangle
p1xyz coordinates of the second vertex of the triangle
p2xyz coordinates of the third vertex of the triangle
pxyz coordinates of the queried point
baryCentricsOutput barycentric coordinates (all in [0, 1] if p belongs to the triangle).
Returns
Returns 0 upon success, negative values otherwise.
Note
Backward compatibility.
bool Geometry::computeSegmentIntersection ( const double &  xA,
const double &  yA,
const double &  xB,
const double &  yB,
const double &  xC,
const double &  yC,
const double &  xD,
const double &  yD,
double &  x,
double &  y 
)
static

Compute the intersection between two 2D segments AB and CD.

Parameters
xAx coordinate of the first vertex of the first segment (AB)
yAy coordinate of the first vertex of the first segment (AB)
xBx coordinate of the second vertex of the first segment (AB)
yBy coordinate of the second vertex of the first segment (AB)
xCx coordinate of the first vertex of the second segment (CD)
yCy coordinate of the first vertex of the second segment (CD)
xDx coordinate of the second vertex of the second segment (CD)
yDy coordinate of the second vertex of the second segment (CD)
xx coordinate of the output intersection (if any).
yy coordinate of the output intersection (if any).
Returns
Returns true if the segments intersect (false otherwise).
int Geometry::computeTriangleAngles ( const double *  p0,
const double *  p1,
const double *  p2,
vector< double > &  angles 
)
static

Compute the angles of a triangle

Parameters
p0xyz coordinates of the first vertex of the triangle
p1xyz coordinates of the second vertex of the triangle
p2xyz coordinates of the third vertex of the triangle
anglesAngles (p0p1, p1p2) (p1p2, p2p0) (p2p0, p0p1)
int Geometry::computeTriangleArea ( const double *  p0,
const double *  p1,
const double *  p2,
double &  area 
)
static

Compute the area of a 3D triangle.

Parameters
p0xyz coordinates of the first vertex of the triangle
p1xyz coordinates of the second vertex of the triangle
p2xyz coordinates of the third vertex of the triangle
areaOutput area.
Returns
Returns 0 upon success, negative values otherwise.
int Geometry::crossProduct ( const double *  vA0,
const double *  vA1,
const double *  vB0,
const double *  vB1,
vector< double > &  crossProduct 
)
static

Compute the cross product of two 3D vectors

Parameters
vA0xyz coordinates of vA's origin
vA1xyz coordinates of vA's destination
vB0xyz coordinates of vB's origin
vB1xyz coordinates of vB's destination
crossProductOutput cross product.
Returns
Returns 0 upon success, negative values otherwise.
int Geometry::crossProduct ( const double *  vA,
const double *  vB,
double *  vC 
)
static

Compute the cross product of two 3D vectors

Parameters
vAxyz coordinates of vA vector
vBxyz coordinates of vB vector
vCOutput cross product.
Returns
Returns 0 upon success, negative values otherwise.
double Geometry::distance ( const double *  p0,
const double *  p1,
const int &  dimension = 3 
)
static

Compute the Euclidean distance between two points

Parameters
p0xyz coordinates of the first input point.
p1xyz coordinates of the second input point.
dimensionOptional parameter that specifies the dimension of the point set (by default 3).
double Geometry::distance ( const float *  p0,
const float *  p1,
const int &  dimension = 3 
)
static

Compute the Euclidean distance between two points

Parameters
p0xyz coordinates of the first input point.
p1xyz coordinates of the second input point.
dimensionOptional parameter that specifies the dimension of the point set (by default 3).
double Geometry::dotProduct ( const double *  vA0,
const double *  vA1,
const double *  vB0,
const double *  vB1 
)
static

Compute the dot product of two 3D vectors

Parameters
vA0xyz coordinates of vA's origin
vA1xyz coordinates of vA's destination
vB0xyz coordinates of vB's origin
vB1xyz coordinates of vB's destination
Returns
Returns Output dot product
double Geometry::dotProduct ( const double *  vA,
const double *  vB 
)
static

Compute the dot product of two 3D vectors

Parameters
vA0xyz coordinates of vA vector
vB0xyz coordinates of vB vector
Returns
Returns Output dot product
int Geometry::getBoundingBox ( const vector< vector< double > > &  points,
vector< pair< double, double >> &  bBox 
)
static

Compute the bounding box of a point set.

Parameters
pointsVector of points. Each entry is a vector whose size is equal to the dimension of the space embedding the points.
bBoxOutput bounding box. The number of entries in this vector is equal to the dimension of the space embedding the points.
Returns
Returns 0 upon success, negative values otherwise.
bool Geometry::isPointInTriangle ( const double *  p0,
const double *  p1,
const double *  p2,
const double *  p 
)
static

Check if the point p is inside the triangle (p0, p1, p2).

Parameters
p0xyz coordinates of the first vertex of the triangle
p1xyz coordinates of the second vertex of the triangle
p2xyz coordinates of the third vertex of the triangle
pxyz coordinates of the queried point
Returns
Returns true if p is in the triangle, false otherwise.
bool Geometry::isPointInTriangle ( const float *  p0,
const float *  p1,
const float *  p2,
const float *  p 
)
static

Check if the point p is inside the triangle (p0, p1, p2).

Parameters
p0xyz coordinates of the first vertex of the triangle
p1xyz coordinates of the second vertex of the triangle
p2xyz coordinates of the third vertex of the triangle
pxyz coordinates of the queried point
Returns
Returns true if p is in the triangle, false otherwise.
bool Geometry::isPointOnSegment ( const double &  x,
const double &  y,
const double &  xA,
const double &  yA,
const double &  xB,
const double &  yB 
)
static

Check if a 2D point xy lies on a 2D segment AB.

Parameters
xx coordinate of the input point.
yy coordinate of the input point.
xAx coordinate of the first vertex of the segment [AB]
yAy coordinate of the first vertex of the segment [AB]
xBx coordinate of the second vertex of the segment [AB]
yBy coordinate of the second vertex of the segment [AB]
Returns
Returns true if the point lies on the segment, false otherwise.
bool Geometry::isPointOnSegment ( const double *  p,
const double *  pA,
const double *  pB,
const int &  dimension = 3 
)
static

Check if a point p lies on a segment AB.

Parameters
pxyz coordinates of the input point.
pAxyz coordinates of the first vertex of the segment [AB]
pBxyz coordinate of the second vertex of the segment [AB]
dimensionOptional parameter that specifies the dimension of the point set (by default 3).
Returns
Returns true if the point lies on the segment, false otherwise.
bool Geometry::isTriangleColinear ( const double *  p0,
const double *  p1,
const double *  p2,
const double *  tolerance = NULL 
)
static

Check if all the edges of a triangle are colinear.

Parameters
p0xyz coordinates of the first vertex of the triangle.
p1xyz coordinates of the second vertex of the triangle.
p2xyz coordinates of the third vertex of the triangle.
Returns
Returns true if all the edges are colinear (false otherwise).
double Geometry::magnitude ( const double *  v)
static

Compute the magnitude of a 3D vector v.

Parameters
vxyz coordinates of the input vector.
Returns
Returns the magnitude upon success, negative values otherwise.
double Geometry::magnitude ( const double *  o,
const double *  d 
)
static

Compute the magnitude of a 3D vector.

Parameters
oxyz coordinates of the vector's origin
dxyz coordinates of the vector's destination

The documentation for this class was generated from the following files: