12 static double dist_plane(
double x,
double y,
const struct plane *p)
14 return x * p->
x + y * p->
y + p->
k;
17 static double interpolate(
double a,
double b,
double ka,
double kb)
19 return (a * kb -
b * ka) / (kb - ka);
22 static void clip_path_plane(
struct path *
dst,
const struct path *
src,
23 const struct plane *p)
28 double d0 = dist_plane(x0, y0, p);
33 for (i = 0; i <
src->count; i++) {
37 double d1 = dist_plane(x1, y1, p);
43 double x = interpolate(x0, x1, d0, d1);
44 double y = interpolate(y0, y1, d0, d1);
50 double x = interpolate(x0, x1, d0, d1);
51 double y = interpolate(y0, y1, d0, d1);
67 static void cull_path_plane(
struct path *
dst,
const struct path *
src,
68 const struct plane *p)
71 int prev =
src->count - 1;
75 double d0 = dist_plane(x0, y0, p);
80 for (i = 0; i <
src->count; i++) {
84 double d1 = dist_plane(x1, y1, p);
88 if (!in0 && in1 && last != prev) {
131 struct path tmp1, tmp2;
136 cull_path_plane(&tmp1,
src, &
clip->left);
137 cull_path_plane(&tmp2, &tmp1, &
clip->rite);
138 cull_path_plane(&tmp1, &tmp2, &
clip->bot);
148 struct path tmp1, tmp2;
153 clip_path_plane(&tmp1,
src, &
clip->left);
154 clip_path_plane(&tmp2, &tmp1, &
clip->rite);
155 clip_path_plane(&tmp1, &tmp2, &
clip->bot);
void D__cull_path(struct path *dst, const struct path *src, const struct clip *clip)
void D__clip_path(struct path *dst, const struct path *src, const struct clip *clip)
void D__set_clip_planes(struct clip *clip, const struct rectangle *rect)
void path_reset(struct path *p)
void path_free(struct path *p)
void path_cont(struct path *p, double x, double y)
void path_move(struct path *p, double x, double y)
void path_init(struct path *p)
struct plane left rite bot top