How to draw a curve approximated to original one
I have a set of points and i want to draw a curve which should be approximated to original curve.
Let say ,in hawk-eye system(used in cricket) i have a set ofco-ordinates of ball during the entire flight of ball , now how can i draw such a curve going through ball's space co-开发者_如何学Pythonordinates and looks appromixately to original curve one method i thought its to get a large number of points such that every two point is very close to each other and then draw a straight light between themCurves are almost always rendered in four steps:
Approximate or interpolate a set of points using a curve or spline algorithm. Choices may include:
- Cubic splines, which pass through all of the data points and produce a smooth curve
- Bézier curves, which do not pass through all the points, but which lie within the envelope of the consecutive groups of 4 points surrounding each curve section.
- Hermite curves, which are defined by a set of points, and a set of tangent vectors: you would need to generate the set of tangent vectors somehow in order to use this sort of curve.
- (and probably more that I've forgotten)
Convert whichever representation you chose to a Bézier Curve: this can be achieved by a simple matrix transformation from other curve types.
Repeatedly subdivide the Bézier curve: the control points tend to approximate the curve.
Draw the control points of the subdivided curve, joined by a straight line.
If you go straight for the Bézier curve, which is probably the easiest, then there are some very simple and elegant methods of subdividing it.
I highly recommend Catmull-Rom splines for this purpose, they are based on Hermite curves. Rather than using 2 points and 2 tangents, it uses the four adjacent data points to interpolate making it better suited/simpler for motion path upsampling.
精彩评论