36#define MIN(a, b) (((a) < (b)) ? (a) : (b))
37#define MAX(a, b) (((a) > (b)) ? (a) : (b))
38#define ABS_DBL(a) ((a) < 0 ? -(a) : (a))
42 double xmin = DBL_MAX, xmax = -DBL_MAX, ymin = DBL_MAX, ymax = -DBL_MAX;
47 if (!conv_func || !box || !vertices)
50 for (list_item = vertices; list_item != NULL; list_item = g_list_next(list_item)) {
53 conv_func((
void *)list_item->data, &temp_vec);
58 xmin =
MIN(xmin, temp_vec.
x);
59 xmax =
MAX(xmax, temp_vec.
x);
60 ymin =
MIN(ymin, temp_vec.
y);
61 ymax =
MAX(ymax, temp_vec.
y);
73 if (!destination || !update)
108 double angle, angle_sin, u;
109 struct vector_2d ba, bc, u_vec, v_vec, ba_norm;
111 if (!a || !b || !c || !m1 || !m2)
129 angle_sin = sin(angle);
130 u = width/(2*angle_sin);
151 GList *vertex_iterator;
154 if (!vertices || !box)
157 for (vertex_iterator = vertices; vertex_iterator != NULL; vertex_iterator = g_list_next(vertex_iterator)) {
159 if (conv_func != NULL)
160 conv_func(vertex_iterator->data, &pt);
178 if (!destination || !pt)
182 conv_func(pt, &point);
220 for (i = 0; i < 4; i++) {
221 input_points[i].
y *= (flip_at_x ? -1 : 1);
Header for calculation of bounding boxes.
void bounding_box_prepare_empty(union bounding_box *box)
Prepare an empty bounding box.
void vector_2d_scale(struct vector_2d *vec, double scale)
#define MIN(a, b)
Return smaller number.
static void calculate_path_miter_points(struct vector_2d *a, struct vector_2d *b, struct vector_2d *c, struct vector_2d *m1, struct vector_2d *m2, double width)
Calculate path miter points for a pathwith a width and the anchors a b c.
void bounding_box_get_all_points(struct vector_2d *points, union bounding_box *box)
Return all four corner points of a bounding box.
void bounding_box_update_with_path(GList *vertices, double thickness, conv_generic_to_vector_2d_t conv_func, union bounding_box *box)
Calculate the bounding box of a path and update the given bounding box.
void vector_2d_rotate(struct vector_2d *vec, double angle)
struct vector_2d * vector_2d_copy(struct vector_2d *opt_res, struct vector_2d *vec)
void vector_2d_normalize(struct vector_2d *vec)
void(* conv_generic_to_vector_2d_t)(void *, struct vector_2d *)
double vector_2d_calculate_angle_between(struct vector_2d *a, struct vector_2d *b)
void vector_2d_subtract(struct vector_2d *res, struct vector_2d *a, struct vector_2d *b)
void vector_2d_add(struct vector_2d *res, struct vector_2d *a, struct vector_2d *b)
void bounding_box_apply_transform(double scale, double rotation_deg, bool flip_at_x, union bounding_box *box)
Apply transformations onto bounding box.
void bounding_box_calculate_from_polygon(GList *vertices, conv_generic_to_vector_2d_t conv_func, union bounding_box *box)
Calculate bounding box of polygon.
void bounding_box_update_with_point(union bounding_box *destination, conv_generic_to_vector_2d_t conv_func, void *pt)
Update bounding box with a point.
void bounding_box_update_with_box(union bounding_box *destination, union bounding_box *update)
Update an exisitng bounding box with another one.
#define MAX(a, b)
Return bigger number.
struct vector_2d upper_right
Upper right point of the bounding box.
struct vector_2d lower_left
Lower left point of the bounding box.
Union describing a bounding box.
struct bounding_box::_vectors vectors