커브 또는 닫힌 경로에서 이러한 작업 중 일부를 구현해야했습니다. 주로 선과 다각형 연산으로 이어집니다. 몇 가지 유용한 개념 :
- 제어점은 베 지어 경로 주위에 볼록한 선체를 형성하며 교차로 관련 작업을 단락시키는 데 유용합니다.
- 커브 세분은 적응력이 있어야합니다. 다음 세분화가 중요한 차이가되지 않을 때 중지됩니다. 즉, "하프"가 다른 깊이로 나뉠 수 있습니다.
- 중간 점뿐만 아니라 어느 지점에서나 커브를 세분 할 수 있습니다. 이는 관심 지점에서 끝나는 베 지어 서브 커브를 만드는 데 유용합니다. 임의 세분
예제 코드 :
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());
}
몇 가지 유용한 사이트 :
이
출처
2011-05-16 00:31:49
xan
나는이 오래 알고 있습니다. 여전히 관련이 있습니까? 다른 세트 작업의 결과는 무엇입니까? 포인트를 공유하지 않는 두 경로의 결합을 취하면 단일 데이터 구조에 두 개의 경로가 저장됩니다. – JCooper