iPhoneで手描きの線を滑らかにしたい。http://webdocs.cs.ualberta.ca/~graphics/books/GraphicsGems/gems/FitCurves.cで次のコードを使用しました 。
しかし、一部のベジェ曲線が間違っていることがわかりました。2 番目の制御点と終点が無効です。誰かが以前に同じ問題を抱えていましたか?ありがとう。
iPhoneで手描きの線を滑らかにしたい。http://webdocs.cs.ualberta.ca/~graphics/books/GraphicsGems/gems/FitCurves.cで次のコードを使用しました 。
しかし、一部のベジェ曲線が間違っていることがわかりました。2 番目の制御点と終点が無効です。誰かが以前に同じ問題を抱えていましたか?ありがとう。
Bezier Curves are not designed to go through the provided vertices! They are designed to shape a smooth curve influenced by the control points.
First you must decide if you want to interpolate between missing points, or if you want to filter non smooth data:
Filtering
You should look at "sliding average" with a small averaging window. (try 5 - 10 pixel). This works as follows: (look for wiki for a detailed description)
I use here an average window of 10 points:
start by calculation of the average of points 0 - 9, and output the result as result point 0
then calculate the average of point 1 - 10 and output, result 1
And so on.
Interpolation If you want to interpolate between (missing) points using a smooth curve, you could use piece - wise cubic splines:
You calculate the coefficients of a cubic polygon through 3 vertices.
You start with calculating the cubic polygon through:
Point[0] - Point[2], but you draw your output only from Point[0] to Point[1] .
Then you move on one step: and calculate through
Point[1] - Point[3], but you draw only from p1 to p2.
And so on.
You need to search on wiki for cubic interpolation for a detailed explanation how to caluclate a cubic polygon (sometimes called cubic spline).