Tarun
Tarun

Reputation: 3165

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-ordinates 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 them

Upvotes: 3

Views: 1536

Answers (2)

cmannett85
cmannett85

Reputation: 22366

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.

Upvotes: 2

James
James

Reputation: 25543

Curves are almost always rendered in four steps:

  1. 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)
  2. Convert whichever representation you chose to a Bézier Curve: this can be achieved by a simple matrix transformation from other curve types.

  3. Repeatedly subdivide the Bézier curve: the control points tend to approximate the curve.

  4. 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.

Upvotes: 5

Related Questions