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. |
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).
vector<PointType*>* ttl_util::createRandomData | ( | int | noPoints, | |
int | seed = 1 | |||
) | [inline] |
Creates random data on the unit square.
noPoints | Number of random points to be generated | |
seed | Initial value for pseudorandom number generator |
PointType::PointType(double x, double y)
.pair<double, double>
.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 }
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.)
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().
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.
Definition at line 119 of file ttl_util.h.
Referenced by hed::TTLtraits::orient2d().
real_type ttl_util::scalarProduct2d | ( | real_type | dx1, | |
real_type | dy1, | |||
real_type | dx2, | |||
real_type | dy2 | |||
) | [inline] |
Scalar product between two 2D vectors.
dx1*dx2 + dy1*dy2
Definition at line 89 of file ttl_util.h.
Referenced by ttl::inTriangle(), and ttl::swapTestDelaunay().