UTGeometry.h File Reference

Go to the source code of this file.

Classes

struct  Point_t
 Struct representing a point in a 2 dimensional coordinate space. More...
struct  Rect_t
 Struct representing a rectangle in a 2 dimensional coordinate space. More...
class  Region_t
 Class representing a region of non-overlapping rectangles, organized into horizontal stripes. More...
class  Polygon_t
 Class representing a polygon in a 2 dimensional coordinate space. More...
struct  Circle_t
 Struct representing a circle in a 2 dimensional coordinate space. More...
class  Ellipse_t
 Class representing an ellipse in a 2 dimensional coordinate space. More...

Defines

#define c_pi   3.1415926535897932384626433832795
#define c_2_pi   6.2831853071795864769252867665590
#define c_pi_div2   1.5707963267948966192313216916398
#define c_3_pi_div2   4.7123889803846898576939650749193
#define c_dbl_abs_min_denominator   1.0e-12
#define c_dbl_abs_min_denominator_squared   1.0e-24
#define c_dbl_abs_min_vh_radial_distance   0.6e-11
#define c_dbl_compare_equality_threshold   0.6e-6

Functions

void expand_to_integer (float *value, bool expand_to_lower_number)
bool find_line_intercept (const Point_t *line_a_from, const Point_t *line_a_to, const Point_t *line_b_from, const Point_t *line_b_to, out Point_t *intercept, bool only_if_line_segments_intercept)
bool find_line_intercept (const Point_t &line_a_from, const Point_t &line_a_to, const Point_t &line_b_from, const Point_t &line_b_to, out Point_t *intercept, bool only_if_line_segments_intercept=true)
bool find_slope_intercept (const Point_t *line_a_from, double line_a_slope, const Point_t *line_b_from, double line_b_slope, out Point_t *intercept)
bool find_slope_intercept (const Point_t &line_a_from, double line_a_slope, const Point_t &line_b_from, double line_b_slope, out Point_t *intercept)
bool find_line_x_intercept (const Point_t *line_a_from, const Point_t *line_a_to, const Point_t *line_b_from, const Point_t *line_b_to, out float *x_intercept, bool only_if_line_segments_intercept)
bool find_line_x_intercept (const Point_t &line_a_from, const Point_t &line_a_to, const Point_t &line_b_from, const Point_t &line_b_to, out float *x_intercept, bool only_if_line_segments_intercept=true)
bool find_slope_x_intercept (const Point_t *line_a_from, double line_a_slope, const Point_t *line_b_from, double line_b_slope, out float *x_intercept)
bool find_slope_x_intercept (const Point_t &line_a_from, double line_a_slope, const Point_t &line_b_from, double line_b_slope, out float *x_intercept)
bool find_line_y_intercept (const Point_t *line_a_from, const Point_t *line_a_to, const Point_t *line_b_from, const Point_t *line_b_to, out float *y_intercept, bool only_if_line_segments_intercept)
bool find_line_y_intercept (const Point_t &line_a_from, const Point_t &line_a_to, const Point_t &line_b_from, const Point_t &line_b_to, out float *y_intercept, bool only_if_line_segments_intercept=true)
bool find_slope_y_intercept (const Point_t *line_a_from, double line_a_slope, const Point_t *line_b_from, double line_b_slope, out float *y_intercept)
bool find_slope_y_intercept (const Point_t &line_a_from, double line_a_slope, const Point_t &line_b_from, double line_b_slope, out float *y_intercept)
void normalize_radians (double *radian)

Define Documentation

#define c_pi   3.1415926535897932384626433832795

Constant for PI, same as M_PI but related nomenclature is more clear, for example c_pi_div2 for PI/2 instead of M_PI_2, and c_2_pi for 2*PI whereas M_2_PI is 2/PI with no standard math constant for 2*PI.

Definition at line 53 of file UTGeometry.h.

#define c_2_pi   6.2831853071795864769252867665590

Constant for 2*PI.

Definition at line 56 of file UTGeometry.h.

#define c_pi_div2   1.5707963267948966192313216916398

Constant for PI/2.

Definition at line 59 of file UTGeometry.h.

#define c_3_pi_div2   4.7123889803846898576939650749193

Constant for 3*PI/2.

Definition at line 62 of file UTGeometry.h.

#define c_dbl_abs_min_denominator   1.0e-12

Constant for the minimum denominator which can reasonably be used in a double-precision floating point divide. The value is based on the fact that an IEEE float has an 8-bit signed exponent, while an IEEE double precision float has an 11-bit signed exponent, but according to opengroup documentation for float.h, DBL_MAX_10_EXP can sometimes be 38, reflecing the 8-bit signed exponent. This constant allocates about 2/3 of the dynamic range to the numerator for that worst case precision for a double.

Definition at line 70 of file UTGeometry.h.

#define c_dbl_abs_min_denominator_squared   1.0e-24

Convenience constant for c_dbl_abs_min_denominator*c_dbl_abs_min_denominator, useful to check before taking the square root of a number then using it as a denominator. If the number is less then there's no need to bother taking the square root.

Definition at line 75 of file UTGeometry.h.

#define c_dbl_abs_min_vh_radial_distance   0.6e-11

Constant for the minimum radial distance from vertical or horizontal which can reasonably be used to generate a slope which is safe in a floating point divide. Often, if the radian is within this distance of being horizontal or vertical, special case treatment is needed. The sine of this number is just over c_dbl_abs_min_denominator.

Definition at line 81 of file UTGeometry.h.

#define c_dbl_compare_equality_threshold   0.6e-6

Constant for the threshold under which, for convenience == and != operators, two coordinates or sizes will be considered to be equal. This is adequate for pixels. For very large values, a custom comparison function should be used.

Definition at line 86 of file UTGeometry.h.


Function Documentation

void expand_to_integer ( float *  value,
bool  expand_to_lower_number 
)

Expands the number to the nearest integer. If it is already within c_dbl_abs_min_denominator of an integer, does not change the value. If expand_to_lower_number is true, the value will become a smaller positive value or a larger negative value. Otherwise, the value will become a larger positive value or a smaller negative value.

bool find_line_intercept ( const Point_t line_a_from,
const Point_t line_a_to,
const Point_t line_b_from,
const Point_t line_b_to,
out Point_t intercept,
bool  only_if_line_segments_intercept 
)

Finds the intercept of two lines. Returns false if they do not intercept (are parallel) or if only_if_line_segments_intercept is true and, even if not parallel, the segments to not touch each other. Returns true if they do intercept, in which case *intercept is set to the intercept point.

bool find_line_intercept ( const Point_t line_a_from,
const Point_t line_a_to,
const Point_t line_b_from,
const Point_t line_b_to,
out Point_t intercept,
bool  only_if_line_segments_intercept = true 
) [inline]

Finds the intercept of two lines. Returns false if they do not intercept (are parallel) or if only_if_line_segments_intercept is true and, even if not parallel, the segments to not touch each other. Returns true if they do intercept, in which case *intercept is set to the intercept point.

Definition at line 1196 of file UTGeometry.h.

bool find_slope_intercept ( const Point_t line_a_from,
double  line_a_slope,
const Point_t line_b_from,
double  line_b_slope,
out Point_t intercept 
)

Finds the intercept of two lines. Returns false if they do not intercept (are parallel). Returns true if are not parallel, in which case *intercept is set to the intercept point.

bool find_slope_intercept ( const Point_t line_a_from,
double  line_a_slope,
const Point_t line_b_from,
double  line_b_slope,
out Point_t intercept 
) [inline]

Finds the intercept of two lines. Returns false if they do not intercept (are parallel). Returns true if are not parallel, in which case *intercept is set to the intercept point.

Definition at line 1213 of file UTGeometry.h.

bool find_line_x_intercept ( const Point_t line_a_from,
const Point_t line_a_to,
const Point_t line_b_from,
const Point_t line_b_to,
out float *  x_intercept,
bool  only_if_line_segments_intercept 
)

Finds the x intercept of two lines. Returns false if they do not intercept (are parallel) or if only_if_line_segments_intercept is true and, even if not parallel, the segments to not touch each other. Returns true if they do intercept, in which case *intercept is set to the x coordinate of the intercept point.

bool find_line_x_intercept ( const Point_t line_a_from,
const Point_t line_a_to,
const Point_t line_b_from,
const Point_t line_b_to,
out float *  x_intercept,
bool  only_if_line_segments_intercept = true 
) [inline]

Finds the x intercept of two lines. Returns false if they do not intercept (are parallel) or if only_if_line_segments_intercept is true and, even if not parallel, the segments to not touch each other. Returns true if they do intercept, in which case *intercept is set to the x coordinate of the intercept point.

Definition at line 1228 of file UTGeometry.h.

bool find_slope_x_intercept ( const Point_t line_a_from,
double  line_a_slope,
const Point_t line_b_from,
double  line_b_slope,
out float *  x_intercept 
)

Finds the x intercept of two lines. Returns false if they do not intercept (are parallel). Returns true if are not parallel, in which case *intercept is set to the x coordinate of the intercept point.

bool find_slope_x_intercept ( const Point_t line_a_from,
double  line_a_slope,
const Point_t line_b_from,
double  line_b_slope,
out float *  x_intercept 
) [inline]

Finds the x intercept of two lines. Returns false if they do not intercept (are parallel). Returns true if are not parallel, in which case *intercept is set to the x coordinate of the intercept point.

Definition at line 1245 of file UTGeometry.h.

bool find_line_y_intercept ( const Point_t line_a_from,
const Point_t line_a_to,
const Point_t line_b_from,
const Point_t line_b_to,
out float *  y_intercept,
bool  only_if_line_segments_intercept 
)

Finds the y intercept of two lines. Returns false if they do not intercept (are parallel) or if only_if_line_segments_intercept is true and, even if not parallel, the segments to not touch each other. Returns true if they do intercept, in which case *intercept is set to the y coordinate of the intercept point.

bool find_line_y_intercept ( const Point_t line_a_from,
const Point_t line_a_to,
const Point_t line_b_from,
const Point_t line_b_to,
out float *  y_intercept,
bool  only_if_line_segments_intercept = true 
) [inline]

Finds the y intercept of two lines. Returns false if they do not intercept (are parallel) or if only_if_line_segments_intercept is true and, even if not parallel, the segments to not touch each other. Returns true if they do intercept, in which case *intercept is set to the y coordinate of the intercept point.

Definition at line 1260 of file UTGeometry.h.

bool find_slope_y_intercept ( const Point_t line_a_from,
double  line_a_slope,
const Point_t line_b_from,
double  line_b_slope,
out float *  y_intercept 
)

Finds the y intercept of two lines. Returns false if they do not intercept (are parallel). Returns true if are not parallel, in which case *intercept is set to the y coordinate of the intercept point.

bool find_slope_y_intercept ( const Point_t line_a_from,
double  line_a_slope,
const Point_t line_b_from,
double  line_b_slope,
out float *  y_intercept 
) [inline]

Finds the y intercept of two lines. Returns false if they do not intercept (are parallel). Returns true if are not parallel, in which case *intercept is set to the y coordinate of the intercept point.

Definition at line 1277 of file UTGeometry.h.

void normalize_radians ( double *  radian  ) 

If the radian value is not in the zero (inclusive) to 2*PI (exclusive) range, shifts it into that range.


Generated on Tue Dec 14 22:35:06 2010 for UT library by  doxygen 1.6.1