How could I perform additional geometry operations along the bezier paths?

I have a library that draws regular patterns of bezier paths (complex paths made up of many bezier points) using the mid-range approximation.

I can draw them without problems, but I need to add support for advanced geometry operations: the closest point of the curve, intersection, the figure contains a point and, more important, combinations of paths: difference, intersection, exception or, union , ...

Is there a good source to get all this?

thank

+3
source share
1 answer

. . :

  • , , .
  • , , , , "" .
  • , , , .

:

 static Point2D.Double[][] splitBezier(Point2D.Double[] p) {
     return splitBezier(p, 0.5);
 }

 static Point2D.Double[][] splitBezier(Point2D.Double[] p, double t) {
    Point2D.Double[][] parts = new Point2D.Double[2][4];
    Point2D.Double ab = interpolate(t, p[0], p[1]);
    Point2D.Double bc = interpolate(t, p[1], p[2]);
    Point2D.Double cd = interpolate(t, p[2], p[3]);
    Point2D.Double abc = interpolate(t, ab, bc);
    Point2D.Double bcd = interpolate(t, bc, cd);
    Point2D.Double abcd = interpolate(t, abc, bcd);
    parts[0][0] = p[0];
    parts[0][1] = ab;
    parts[0][2] = abc;
    parts[0][3] = abcd;
    parts[1][0] = abcd;
    parts[1][2] = bcd;
    parts[1][2] = cd;
    parts[1][3] = p[3];
    return parts;
 }

 static Point2D.Double interpolate(double t, Point2D.Double a, Point2D.Double b) {
    return new Point2D.Double((1 - t) * a.getX() + t * b.getX(),
                              (1 - t) * a.getY() + t * b.getY());
 }

:

  • (PDF)
+1

Source: https://habr.com/ru/post/1737803/


All Articles