-
-
Save seanchas116/5b1b5f2d9f5835195afafba83314a3ce to your computer and use it in GitHub Desktop.
Cubic B-spline から ベジエの制御点に変換
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function cubicBSpline(P0: Point, P1: Point, P2: Point, P3: Point): [Point, Point, Point, Point] { | |
const x0 = (P0[0] + 4 * P1[0] + P2[0]) / 6; | |
const y0 = (P0[1] + 4 * P1[1] + P2[1]) / 6; | |
const x1 = (2 * P1[0] + P2[0]) / 3; | |
const y1 = (2 * P1[1] + P2[1]) / 3; | |
const x2 = (P1[0] + 2 * P2[0]) / 3; | |
const y2 = (P1[1] + 2 * P2[1]) / 3; | |
const x3 = (P1[0] + 4 * P2[0] + P3[0]) / 6; | |
const y3 = (P1[1] + 4 * P2[1] + P3[1]) / 6; | |
return [ | |
[x0, y0], | |
[x1, y1], | |
[x2, y2], | |
[x3, y3], | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment