ttl_util Namespace Reference

Utilities. More...

Functions

Computational geometry



template<class real_type >
real_type scalarProduct2d (real_type dx1, real_type dy1, real_type dx2, real_type dy2)
 Scalar product between two 2D vectors.
template<class real_type >
real_type crossProduct2d (real_type dx1, real_type dy1, real_type dx2, real_type dy2)
 Cross product between two 2D vectors.
template<class real_type >
real_type orient2dfast (real_type pa[2], real_type pb[2], real_type pc[2])
 Returns a positive value if the 2D nodes/points pa, pb, and pc occur in counterclockwise order; a negative value if they occur in clockwise order; and zero if they are collinear.
Utilities involving points



template<class PointType >
vector< PointType * > * createRandomData (int noPoints, int seed=1)
 Creates random data on the unit square.

Detailed Description

Utilities.

This name space contains utility functions for TTL.

Point and vector algebra such as scalar product and cross product between vectors are implemented here. These functions are required by functions in the ttl namespace, where they are assumed to be present in the TTLtraits class. Thus, the user can call these functions from the traits class. For efficiency reasons, the user may consider implementing these functions in the the API directly on the actual data structure; see Application Programming Interface to TTL (API).

Note:
  • Cross product between vectors in the xy-plane delivers a scalar, which is the z-component of the actual cross product (the x and y components are both zero).
See also:
ttl and Application Programming Interface to TTL (API)
Author:
Øyvind Hjelle, oyvindhj@ifi.uio.no

Function Documentation

template<class PointType >
vector<PointType*>* ttl_util::createRandomData ( int  noPoints,
int  seed = 1 
) [inline]

Creates random data on the unit square.

Parameters:
noPoints Number of random points to be generated
seed Initial value for pseudorandom number generator
  • Constructor PointType::PointType(double x, double y).
    For example, one can use pair<double, double>.
Note:
  • To deduce template argument for PointType the function must be called with the syntax: createRandomData<MyPoint>(...) where MyPoint is the actual point type.

Definition at line 265 of file ttl_util.h.

00265                                                                    {
00266     
00267 #ifdef _MSC_VER
00268     srand(seed);
00269 #else
00270     srand48((long int)seed);
00271 #endif
00272     
00273     double x, y;
00274     vector<PointType*>* points = new vector<PointType*>(noPoints);
00275     typename vector<PointType*>::iterator it;
00276     for (it = points->begin(); it != points->end(); ++it) {
00277 
00278 #ifdef _MSC_VER
00279       int random = rand();
00280       x = ((double)random/(double)RAND_MAX);
00281       random = rand();
00282       y = ((double)random/(double)RAND_MAX);
00283       *it = new PointType(x,y);
00284 #else
00285       double random = drand48();
00286       x = random;
00287       random = drand48();
00288       y = random;
00289       *it = new PointType(x,y);
00290 #endif
00291 
00292     }
00293     return points;
00294   }

template<class real_type >
real_type ttl_util::crossProduct2d ( real_type  dx1,
real_type  dy1,
real_type  dx2,
real_type  dy2 
) [inline]

Cross product between two 2D vectors.

(The z-component of the actual cross product.)

Returns:
   dx1*dy2 - dy1*dx2

Definition at line 103 of file ttl_util.h.

Referenced by ttl::convexBoundary(), ttl::degenerateTriangle(), ttl::inTriangle(), ttl::swappableEdge(), and ttl::swapTestDelaunay().

00103                                                                                          {
00104     return dx1*dy2 - dy1*dx2;
00105   }

template<class real_type >
real_type ttl_util::orient2dfast ( real_type  pa[2],
real_type  pb[2],
real_type  pc[2] 
) [inline]

Returns a positive value if the 2D nodes/points pa, pb, and pc occur in counterclockwise order; a negative value if they occur in clockwise order; and zero if they are collinear.

Note:

Definition at line 119 of file ttl_util.h.

Referenced by hed::TTLtraits::orient2d().

00119                                                                               {
00120     real_type acx = pa[0] - pc[0];
00121     real_type bcx = pb[0] - pc[0];
00122     real_type acy = pa[1] - pc[1];
00123     real_type bcy = pb[1] - pc[1];
00124     return acx * bcy - acy * bcx;
00125   }

template<class real_type >
real_type ttl_util::scalarProduct2d ( real_type  dx1,
real_type  dy1,
real_type  dx2,
real_type  dy2 
) [inline]

Scalar product between two 2D vectors.

Returns:
   dx1*dx2 + dy1*dy2

Definition at line 89 of file ttl_util.h.

Referenced by ttl::inTriangle(), and ttl::swapTestDelaunay().

00089                                                                                           {
00090     return dx1*dx2 + dy1*dy2;
00091   }


Generated on Wed Nov 17 17:44:28 2010 for TTL by  doxygen 1.6.1