This is a collection of generic utility procedures that help with various geometric computations.
Computes a rectangular bounding box [mx,Mx] × [my,My] for a set of points in R2.
- param num_nodes
[Input] The number of nodes N we are bounding.
- type num_nodes
const int*
- param nodes
[Input] The actual nodes as a 2 × N array. This should be laid out in Fortran order, with 2N total values.
- type nodes
const double*
- param double* left
[Output] The minimal x-value mx.
- param double* right
[Output] The maximal x-value Mx.
- param double* bottom
[Output] The minimal y-value my.
- param double* top
[Output] The maximal y-value My.
Signature:
void BEZ_bbox(const int *num_nodes, const double *nodes, double *left, double *right, double *bottom, double *top);
Checks if a point p is contained in the bounding box for a set of points.
- param num_nodes
[Input] The number of nodes N define the bounding box.
- type num_nodes
const int*
- param dimension
[Input] The dimension D such that the nodes and point lie in RD.
- type dimension
const int*
- param nodes
[Input] The actual nodes as a D × N array. This should be laid out in Fortran order, with DN total values.
- type nodes
const double*
- param point
[Input] The point p as an array containing D values.
- type point
const double*
- param bool* predicate
[Output] Flag indicating if the point lies inside the box.
Signature:
void BEZ_contains_nd(const int *num_nodes, const int *dimension, const double *nodes, const double *point, bool *predicate);
Computes the cross-product of two vectors v1, v2 in R2. This is done as if they were embedded in R3 and the result is the resulting z-component x1y2 − x2y1.
- param vec0
[Input] The first vector v1 in R2.
- type vec0
const double*
- param vec1
[Input] The second vector v2 in R2.
- type vec1
const double*
- param double* result
[Output] The cross-product.
Signature:
void BEZ_cross_product(const double *vec0, const double *vec1, double *result);
Checks if a value v is in an interval [s,e].
- param value
[Input] The value v.
- type value
const double*
- param start
[Input] The start s of the interval [s,e].
- type start
const double*
- param end
[Input] The end e of the interval [s,e].
- type end
const double*
- returns
Flag indicating if v ∈ [s,e].
- rtype
bool
Signature:
bool BEZ_in_interval(const double *value, const double *start, const double *end);
Determines if two polygons collide.
- param polygon_size1
[Input] The number of sides N1 in the first polygon.
- type polygon_size1
const int*
- param polygon1
[Input] The nodes of the first polygon as a 2 × N1 array. This should be laid out in Fortran order.
- type polygon1
const double*
- param polygon_size2
[Input] The number of sides N2 in the second polygon.
- type polygon_size2
const int*
- param polygon2
[Input] The nodes of the second polygon as a 2 × N2 array. This should be laid out in Fortran order.
- type polygon2
const double*
- param bool* collision
[Output] Flag indicating if the polygons collide.
Signature:
void BEZ_polygon_collide(const int *polygon_size1, const double *polygon1, const int *polygon_size2, const double *polygon2, bool *collision);
Computes the convex hull of a set of points.
- param num_points
[Input] The number of points N.
- type num_points
const int*
- param points
[Input] The points being considered, as a 2 × N array. This should be laid out in Fortran order.
- type points
const double*
- param int* polygon_size
[Output] The number of sides M in the convex hull. This will be at most N.
- param double* polygon
[Output] The nodes in the convex hull, as a 2 × N array laid out in Fortran order. This must be allocated by the caller and must be size N to account for the extreme case.
Signature:
void BEZ_simple_convex_hull(const int *num_points, const double *points, int *polygon_size, double *polygon);
Determines if two vectors are close to machine precision.
- param num_values
[Input] The dimension D such that the vectors lie in RD.
- type num_values
const int*
- param vec1
[Input] The first vector v1, as an array of D values.
- type vec1
const double*
- param vec2
[Input] The second vector v2, as an array of D values.
- type vec2
const double*
- param eps
[Input] The tolerance ε used when comparing ∥v1−v2∥ to ∥v1∥ and ∥v2∥.
- type eps
const double*
- returns
Flag indicating if v1 and v2 are close to the desired precision.
- rtype
bool
Signature:
bool BEZ_vector_close(const int *num_values, const double *vec1, const double *vec2, const double *eps);
Round a value v into the unit interval if it is sufficiently close. The real line will be broken into five intervals and handled differently on each interval:
- v ∈ (−∞,−2 − 44] will not be rounded and will set
success
toFALSE
.- v ∈ (−2 − 44,2 − 44) will be rounded to
0.0
.- v ∈ [2 − 44,1−2 − 44] will be left untouched (i.e. they are safely in the unit interval).
- v ∈ (1−2 − 44,1+2 − 44) will be rounded to
1.0
.- v ∈ [1+2 − 44,∞) will not be rounded and will set
success
toFALSE
.
- param value
[Input] The value v to be rounded.
- type value
const double*
- param double* result
[Output] The rounded version of v. If
success
isFALSE
this is undefined.- param bool* success
[Output] Flag indicating if v was in the unit interval or sufficiently close to it.
Signature:
void BEZ_wiggle_interval(const double *value, double *result, bool *success);