Rename functions of bounding box to be more consistent

This commit is contained in:
Mario Hüttel 2020-01-14 19:03:26 +01:00
parent f11e11e6a7
commit 5a43a8a4bf
3 changed files with 10 additions and 10 deletions

View File

@ -37,7 +37,7 @@
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) /**< @brief Return bigger number */ #define MAX(a, b) (((a) > (b)) ? (a) : (b)) /**< @brief Return bigger number */
#define ABS_DBL(a) ((a) < 0 ? -(a) : (a)) #define ABS_DBL(a) ((a) < 0 ? -(a) : (a))
void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box) void bounding_box_calculate_from_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box)
{ {
double xmin = DBL_MAX, xmax = -DBL_MAX, ymin = DBL_MAX, ymax = -DBL_MAX; double xmin = DBL_MAX, xmax = -DBL_MAX, ymin = DBL_MAX, ymax = -DBL_MAX;
struct vector_2d temp_vec; struct vector_2d temp_vec;
@ -68,7 +68,7 @@ void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t
box->vectors.upper_right.y = ymax; box->vectors.upper_right.y = ymax;
} }
void bounding_box_update_box(union bounding_box *destination, union bounding_box *update) void bounding_box_update_with_box(union bounding_box *destination, union bounding_box *update)
{ {
if (!destination || !update) if (!destination || !update)
return; return;
@ -171,7 +171,7 @@ void bounding_box_update_with_path(GList *vertices, double thickness,
} }
} }
void bounding_box_update_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt) void bounding_box_update_with_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt)
{ {
struct vector_2d point; struct vector_2d point;
@ -222,7 +222,7 @@ void bounding_box_apply_transform(double scale, double rotation_deg, bool flip_a
vector_2d_rotate(&input_points[i], rotation_deg * M_PI / 180.0); vector_2d_rotate(&input_points[i], rotation_deg * M_PI / 180.0);
vector_2d_scale(&input_points[i], scale); vector_2d_scale(&input_points[i], scale);
bounding_box_update_point(box, NULL, &input_points[i]); bounding_box_update_with_point(box, NULL, &input_points[i]);
} }
} }

View File

@ -53,7 +53,7 @@ static void update_box_with_gfx(union bounding_box *box, struct gds_graphics *gf
case GRAPHIC_BOX: case GRAPHIC_BOX:
/* Expected fallthrough */ /* Expected fallthrough */
case GRAPHIC_POLYGON: case GRAPHIC_POLYGON:
bounding_box_calculate_polygon(gfx->vertices, bounding_box_calculate_from_polygon(gfx->vertices,
(conv_generic_to_vector_2d_t)&convert_gds_point_to_2d_vector, (conv_generic_to_vector_2d_t)&convert_gds_point_to_2d_vector,
&current_box); &current_box);
break; break;
@ -74,7 +74,7 @@ static void update_box_with_gfx(union bounding_box *box, struct gds_graphics *gf
} }
/* Update box with results */ /* Update box with results */
bounding_box_update_box(box, &current_box); bounding_box_update_with_box(box, &current_box);
} }
void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell) void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell)
@ -113,7 +113,7 @@ void calculate_cell_bounding_box(union bounding_box *box, struct gds_cell *cell)
temp_box.vectors.upper_right.y += sub_cell->origin.y; temp_box.vectors.upper_right.y += sub_cell->origin.y;
/* update the parent's box */ /* update the parent's box */
bounding_box_update_box(box, &temp_box); bounding_box_update_with_box(box, &temp_box);
} }
} }

View File

@ -81,14 +81,14 @@ typedef void (*conv_generic_to_vector_2d_t)(void *, struct vector_2d *);
* @param conv_func Conversion function to convert vertices to vector_2d structs. * @param conv_func Conversion function to convert vertices to vector_2d structs.
* @param box Box to write to. This box is not updated! All previous data is discarded * @param box Box to write to. This box is not updated! All previous data is discarded
*/ */
void bounding_box_calculate_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box); void bounding_box_calculate_from_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box);
/** /**
* @brief Update an exisitng bounding box with another one. * @brief Update an exisitng bounding box with another one.
* @param destination Target box to update * @param destination Target box to update
* @param update Box to update the target with * @param update Box to update the target with
*/ */
void bounding_box_update_box(union bounding_box *destination, union bounding_box *update); void bounding_box_update_with_box(union bounding_box *destination, union bounding_box *update);
/** /**
* @brief Prepare an empty bounding box. * @brief Prepare an empty bounding box.
@ -105,7 +105,7 @@ void bounding_box_prepare_empty(union bounding_box *box);
* @param conv_func Conversion function to convert \p pt to a vector_2d. May be NULL * @param conv_func Conversion function to convert \p pt to a vector_2d. May be NULL
* @param pt Point to update bounding box with * @param pt Point to update bounding box with
*/ */
void bounding_box_update_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt); void bounding_box_update_with_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt);
/** /**
* @brief Return all four corner points of a bounding box * @brief Return all four corner points of a bounding box