#include "geomlib/curve.h"
#include "geomlib/fpath.h"
Go to the source code of this file.
Data Structures | |
| struct | geom_bezier_subdivision |
Defines | |
| #define | geom_bezier_VMT geom_curve_VMT |
| #define | geom_bezier_INIT |
| #define | GEOM_BEZIER_LINEAR 1 |
| #define | GEOM_BEZIER_QUADRATIC 2 |
| #define | GEOM_BEZIER_CUBIC 3 |
| #define | GEOM_BEZIER_NONRATIONAL 0x100 |
| #define | GEOM_BEZIER_BBOX_VALID 0x200 |
| #define | GEOM_BEZIER_ALENGTH_VALID 0x400 |
| #define | GEOM_BEZIER_DEGREE(b) (*(u8 *)&GEOM_INSTANCE_FLAGS(b)) |
| #define | GEOM_BEZIER_SUBDIVISION_MAX 25 |
| #define | GEOM_BEZIER_SUBDIVIDE_BEGIN(name, bez, part, depth, left, right, max_depth, test) |
| Macro implements recursive subdivision of Bezier curve. | |
| #define | GEOM_BEZIER_SUBDIVIDE_END(name) }} name##_break:; if (0) goto name##_break; }while(0) |
| #define | GEOM_BEZIER_SUBDIVIDE_BREAK(name) goto name##_break; |
| #define | GEOM_BEZIER_DIRECTION_NOBACK 0x00000100 |
| Flag used in geom_bezier_direction_times. | |
| #define | GEOM_BEZIER_EXTREME_MIN 0x00000001 |
| #define | GEOM_BEZIER_EXTREME_MAX 0x00000002 |
| #define | GEOM_BEZIER_EXTREME_GLOBAL 0x00000004 |
| #define | GEOM_BEZIER_EXTREME_LOCAL 0x00000000 |
| #define | GEOM_BEZIER_EXTREME_LIMITS 0x00000008 |
| #define | GEOM_BEZIER_EXTREME_ALL (GEOM_BEZIER_EXTREME_MIN | GEOM_BEZIER_EXTREME_MAX) |
| #define | GEOM_BEZIER_PARAM_TO_CUBIC_NONRATIONAL_BEGIN(_name, _b, _left, _right, _part) |
| #define | GEOM_BEZIER_PARAM_TO_CUBIC_NONRATIONAL_END(_name) } GEOM_BEZIER_SUBDIVIDE_END(_name##_sub); } \ |
| #define | GEOM_BEZIER_SHAPE_TO_CUBIC_NONRATIONAL_BEGIN(_name, _b, _left, _right, _part) GEOM_BEZIER_PARAM_TO_CUBIC_NONRATIONAL_BEGIN(_name, _b, _left, _right, _part) |
| #define | GEOM_BEZIER_SHAPE_TO_CUBIC_NONRATIONAL_END(_name) GEOM_BEZIER_PARAM_TO_CUBIC_NONRATIONAL_END(_name) |
Functions | |
| GEOM_CLASS_HEAD (bezier, curve) | |
| void | geom_bezier_create (struct geom_bezier *bezier) |
| Default Bezier curve constructor. | |
| void | geom_bezier_destroy (struct geom_bezier *bezier) |
| Destructor. | |
| void | geom_bezier_set_linear_nonrational (struct geom_bezier *bezier, struct geom_point *pt0, struct geom_point *pt1) |
| Sets nonrational Bezier curve from two control points. | |
| void | geom_bezier_set_linear_rational (struct geom_bezier *bezier, struct geom_point_w *pt0, struct geom_point_w *pt1) |
| Sets rational Bezier curve from two control points and weights. | |
| void | geom_bezier_set_quadratic_nonrational (struct geom_bezier *bezier, struct geom_point *pt0, struct geom_point *pt1, struct geom_point *pt2) |
| Sets nonrational Bezier curve from three control points. | |
| void | geom_bezier_set_quadratic_rational (struct geom_bezier *bezier, struct geom_point_w *pt0, struct geom_point_w *pt1, struct geom_point_w *pt2) |
| Sets rational Bezier curve from three control points. | |
| void | geom_bezier_set_cubic_nonrational (struct geom_bezier *bezier, struct geom_point *pt0, struct geom_point *pt1, struct geom_point *pt2, struct geom_point *pt3) |
| Sets nonrational Bezier curve from four control points. | |
| void | geom_bezier_set_cubic_rational (struct geom_bezier *bezier, struct geom_point_w *pt0, struct geom_point_w *pt1, struct geom_point_w *pt2, struct geom_point_w *pt3) |
| Sets rational Bezier curve from four control points. | |
| void | geom_bezier_set_rational (struct geom_bezier *bezier) |
| void | geom_bezier_set_nonrational (struct geom_bezier *bezier) |
| int | geom_bezier_valid (struct geom_bezier *bezier) |
| void | geom_bezier_subdump (struct geom_bezier *bezier, uns flags) |
| void | geom_bezier_after_change (struct geom_bezier *bezier) |
| void | geom_bezier_copy (struct geom_bezier *bezier, struct geom_bezier *src) |
| real | geom_bezier_alength (struct geom_bezier *bezier) |
| real | geom_bezier_time_to_atime (struct geom_bezier *bezier, real time) |
| int | geom_bezier_times_to_atimes (struct geom_bezier *bezier, uns count, real *times, real *atimes) |
| real | geom_bezier_atime_to_time (struct geom_bezier *bezier, real atime) |
| int | geom_bezier_atimes_to_times (struct geom_bezier *bezier, uns count, real *atimes, real *times) |
| int | geom_bezier_expansion_append (struct geom_bezier *bezier, struct geom_fpath *expansion) |
| int | geom_bezier_to_bezier (struct geom_bezier *bezier, struct geom_bezier *result) |
| int | geom_bezier_conversion_append (struct geom_bezier *bezier, uns flags, struct geom_fpath *result) |
| int | geom_bezier_transform (struct geom_bezier *bezier, struct geom_transform *transform, struct geom_bezier *result) |
| int | geom_bezier_point_start (struct geom_bezier *bezier, struct geom_point *result) |
| int | geom_bezier_point_end (struct geom_bezier *bezier, struct geom_point *result) |
| int | geom_bezier_point_at_time (struct geom_bezier *bezier, real time, struct geom_point *result) |
| int | geom_bezier_derivation_start (struct geom_bezier *bezier, struct geom_vector *result) |
| int | geom_bezier_derivation_end (struct geom_bezier *bezier, struct geom_vector *result) |
| int | geom_bezier_derivation_at_time (struct geom_bezier *bezier, real time, struct geom_vector *result) |
| int | geom_bezier_bbox (struct geom_bezier *bezier, struct geom_rectangle *bbox) |
| int | geom_bezier_nearest_to_point (struct geom_bezier *bezier, struct geom_point *point, uns flags, struct geom_nearest *nearest) |
| int | geom_bezier_distance_times (struct geom_bezier *bezier, struct geom_point *point, real dist, struct garr *result) |
| int | geom_bezier_split_middle (struct geom_bezier *b, struct geom_bezier *left, struct geom_bezier *right) |
| void | geom_bezier_subdivision_init (struct geom_bezier_subdivision *s, struct geom_bezier *b) |
| void | geom_bezier_subdivision_destroy (struct geom_bezier_subdivision *s) |
| geom_bezier * | geom_bezier_subdivision_next (struct geom_bezier_subdivision *s) |
| void | geom_bezier_subdivision_split (struct geom_bezier_subdivision *s) |
| real | geom_bezier_nonrational_error (struct geom_bezier *bezier) |
| int | geom_beziers_intersections (struct geom_bezier *bezier1, struct geom_bezier *bezier2, uns flags, struct garr *result) |
| Finds intersections of two given Bezier curves. | |
| void | geom_bezier_fill_linear_nonrational (struct geom_bezier *bezier, real x0, real y0, real x1, real y1) |
| int | geom_bezier_direction_times (struct geom_bezier *b, struct geom_point *v, uns flags, real result[]) |
| Function finds parameters, where the curve is parallel to a given vector. If the whole curve is parallel to v or v is zero vector, no values are returned. Otherwise, there are at most 1, 3, 2 or 5 solutions for quadratic nonrational, quadratic rational, cubic nonrational or cubic rational curves respectively. We can also set flag GEOM_SOLVE_LEFT_ONLY (return only left most solution, if any) and/or GEOM_BEZIER_DIRECTION_NOBACK (skip solutions with negative derivation in the vector direction). | |
| int | geom_bezier_split_at (struct geom_bezier *b, real t, struct geom_bezier *left, struct geom_bezier *right) |
| Function splits a bezier curve at given parameter t and returns its two parts. Parameters outside the range <0, 1> are aligned to this interval. | |
| int | geom_bezier_reverse (struct geom_bezier *b, struct geom_bezier *result) |
| Function returns the same bezier curve, but with reversed parametrization. | |
| int | geom_bezier_part (struct geom_bezier *b, double t, double s, struct geom_bezier *result) |
| Function returns part of bezier curve given by an interval <t, s>. If t > s, parametrization of resulting path is reversed. Parameters outside the range <0, 1> are aligned to this interval. | |
| int | geom_bezier_elevate (struct geom_bezier *b, uns degree, struct geom_bezier *result) |
| Function increases bezier curve degree to degree. Resulting curve has the same parametrization as the original. | |
| int | geom_bezier_control_box (struct geom_bezier *b, struct geom_rectangle *bbox) |
| Function returns bounding box of given bezier curve control points. Usually, this region is larger than the exact curve bounding box, but is easier to compute. | |
| double | geom_bezier_time_of (struct geom_bezier *b, struct geom_point *p) |
| Function returns parameter of a given point very close to curve. | |
| int | geom_bezier_intersection_times (struct geom_bezier *b1, struct geom_bezier *b2, uns flags, double result1[], double result2[]) |
| Function returns sorted list of parameters, where has the curve given y coordinate. If the whole curve is parallel to x axis, no intersections are returned, otherwise, there are at most curve degree intersections. We can also set flags GEOM_SOLVE_LEFT_ONLY (only left most parameter returned, if any) or GEOM_SOLVE_MULTIPLICITY (higher degree intersections are returned as more equal values). | |
| int | geom_bezier_center_extreme_times (struct geom_bezier *b, struct geom_point *p, uns flags, double result[]) |
| Function finds extreme points on bezier curve. Used metric is distance from given center point. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s). | |
| int | geom_bezier_center_extreme_points (struct geom_bezier *b, struct geom_point *p, uns flags, struct geom_point result[]) |
| Function finds extreme points on bezier curve. Used metric is distance from given center point. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s). | |
| int | geom_bezier_direction_extreme_times (const struct geom_bezier *b, const struct geom_point *v, uns flags, double result[]) |
| Function finds extreme points on bezier curve. Used metric is distance in given direction vector. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s). | |
| int | geom_bezier_direction_extreme_points (struct geom_bezier *b, const struct geom_point *v, uns flags, struct geom_point result[]) |
| Function finds extreme points on bezier curve. Used metric is distance in given direction vector. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s). | |
| int | geom_bezier_approximate (struct geom_bezier *b, double delta, double **buffer, int *buffer_size, int *points) |
| Function returns approximation of bezier curve as a sequence of points (returned in buffer as x, y pairs) with error limited by delta. | |
| int | geom_bezier_cubic_nonrational_enough (struct geom_bezier *b) |
| int | geom_bezier_to_cubic_nonrational (struct geom_bezier *b) |
Copyright (c) 2004-2005 The VRR Team <vrr@ucw.cz> This program is distributed under GNU General Public License, see COPYING.
|
|
Value: { struct geom_bezier _name##_cub; \
geom_bezier_elevate((_b), GEOM_BEZIER_CUBIC, &_name##_cub); \
GEOM_BEZIER_SUBDIVIDE_BEGIN(_name##_sub, &_name##_cub, _part, _name##_deep, _left, _right, 4, \
geom_bezier_cubic_nonrational_enough(_part)) { \
_part->pt[0].w = _part->pt[1].w = _part->pt[2].w = _part->pt[3].w = 1; \
_part->flags |= GEOM_BEZIER_NONRATIONAL;
|
|
|
Value: do{ struct geom_bezier *part, name##_s[(max_depth) + 2]; \ uns depth, name##_t, name##_d[(max_depth) + 2]; \ real left, right, name##_l[(max_depth) + 2]; \ GEOM_ITEM_ASSERT(bezier, bez); \ GEOM_INSTANCE_CREATE2(&name##_s[1], bezier, geom_bezier_copy, bez); \ name##_t = 1; \ name##_d[1] = 0; name##_l[1] = 0; name##_l[0] = 1; \ while (name##_t) { \ depth = name##_d[name##_t]; \ part = &name##_s[name##_t]; \ left = name##_l[name##_t]; \ right = name##_l[name##_t - 1]; \ if (depth < max_depth && !(test)) { \ GEOM_INSTANCE_INIT(&name##_s[name##_t + 1], bezier); \ geom_bezier_split_middle(&name##_s[name##_t], \ &name##_s[name##_t + 1], &name##_s[name##_t]); \ name##_d[name##_t + 1] = ++name##_d[name##_t]; \ if (!isfinite(name##_l[name##_t] = 0.5 * (name##_l[name##_t - 1] + \ (name##_l[name##_t + 1] = name##_l[name##_t])))) \ name##_l[name##_t] = name##_l[name##_t - 1]; \ name##_t++; } \ else { GEOM_INSTANCE_DESTROY2(&name##_s[name##_t], bezier); \ name##_t--; \ Given condition statement is evaluated in each node of subdivision tree to decide whether subdivide or not. Main code is executed only for leaf nodes. Description of current node is stored in varriables depth, left, right and part. Usage: struct geom_bezier *bezier = ???; GEOM_BEZIER_SUBDIVIDE_BEGIN(walk1, bezier, part, depth, left, right, 3, 1) { msg("Depth of subdivision = %d, current interval = (%f, %f)\n", depth, left, right); geom_bezier_dump(part); } GEOM_BEZIER_SUBDIVIDE_END(walk1);
|
|
||||||||||||||||||||||||
|
Function returns approximation of bezier curve as a sequence of points (returned in buffer as x, y pairs) with error limited by delta.
|
|
||||||||||||||||||||
|
Function finds extreme points on bezier curve. Used metric is distance from given center point. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s).
|
|
||||||||||||||||||||
|
Function finds extreme points on bezier curve. Used metric is distance from given center point. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s).
|
|
||||||||||||
|
Function returns bounding box of given bezier curve control points. Usually, this region is larger than the exact curve bounding box, but is easier to compute.
|
|
|
Default Bezier curve constructor. Resulting structure is invalid curve and must be set by geom_bezier_set_x or destroyed. |
|
||||||||||||||||||||
|
Function finds extreme points on bezier curve. Used metric is distance in given direction vector. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s).
|
|
||||||||||||||||||||
|
Function finds extreme points on bezier curve. Used metric is distance in given direction vector. It is possible to find global (flag GEOM_BEZIER_EXTREME_GLOBAL) or all local extremes (GEOM_BEZIER_EXTREME_LOCAL). With GEOM_BEZIER_EXTREME_MIN set, result contains global/local minimum(s), with GEOM_BEZIER_EXTREME_MAX maximum(s) and with GEOM_BEZIER_EXTREME_ALL both minimum(s) and maximum(s).
|
|
||||||||||||||||||||
|
Function finds parameters, where the curve is parallel to a given vector. If the whole curve is parallel to v or v is zero vector, no values are returned. Otherwise, there are at most 1, 3, 2 or 5 solutions for quadratic nonrational, quadratic rational, cubic nonrational or cubic rational curves respectively. We can also set flag GEOM_SOLVE_LEFT_ONLY (return only left most solution, if any) and/or GEOM_BEZIER_DIRECTION_NOBACK (skip solutions with negative derivation in the vector direction).
|
|
||||||||||||||||
|
Function increases bezier curve degree to degree. Resulting curve has the same parametrization as the original.
|
|
||||||||||||||||||||||||
|
Function returns sorted list of parameters, where has the curve given y coordinate. If the whole curve is parallel to x axis, no intersections are returned, otherwise, there are at most curve degree intersections. We can also set flags GEOM_SOLVE_LEFT_ONLY (only left most parameter returned, if any) or GEOM_SOLVE_MULTIPLICITY (higher degree intersections are returned as more equal values).
|
|
||||||||||||||||||||
|
Function returns part of bezier curve given by an interval <t, s>. If t > s, parametrization of resulting path is reversed. Parameters outside the range <0, 1> are aligned to this interval.
|
|
||||||||||||
|
Function returns the same bezier curve, but with reversed parametrization.
|
|
||||||||||||||||||||||||
|
Sets nonrational Bezier curve from four control points. Can be used as constructor.
|
|
||||||||||||||||||||||||
|
Sets rational Bezier curve from four control points. Can be used as constructor.
|
|
||||||||||||||||
|
Sets nonrational Bezier curve from two control points. Can be used as constructor.
|
|
||||||||||||||||
|
Sets rational Bezier curve from two control points and weights. Can be used as constructor.
|
|
||||||||||||||||||||
|
Sets nonrational Bezier curve from three control points. Can be used as constructor.
|
|
||||||||||||||||||||
|
Sets rational Bezier curve from three control points. Can be used as constructor.
|
|
||||||||||||||||||||
|
Function splits a bezier curve at given parameter t and returns its two parts. Parameters outside the range <0, 1> are aligned to this interval.
|
|
||||||||||||
|
Function returns parameter of a given point very close to curve.
|
|
||||||||||||||||||||
|
Finds intersections of two given Bezier curves. Intersections (geom_intersection structures) are added to current position of a growing array structure.
|
1.3.5