开发者

How to optimally plot parametric continuous curve?

开发者 https://www.devze.com 2023-01-25 03:17 出处:网络
Let\'s say we have a parametric curve, for example a circle: x = r * cos(t) y = r * sin(t) We want to plot the curve on the screen in away that:

Let's say we have a parametric curve, for example a circle:

  x = r * cos(t)
  y = r * sin(t)

We want to plot the curve on the screen in a way that:

  • every pixel is painted just once (the optimal par开发者_如何学编程t)
  • there is a painted pixel for each (x, y) that lies on the curve (the continuous part)

If we just plot (x, y) for each t in [t1, t2], these conditions will not be met.

I am searching for a general solution for any parametric curve.


A general solution that 100% satisfies your criteria does not exist.

So we have to compromize.

Usually this is tackled by starting with a stepsize (usually a parameter to your routine), this stepsize can be subdivided triggered by a heuristic e.g.:

  • subdivide when the distance covered by a segment is larger than a given distance (e.g. one pixel)

  • subdivide when the curve direction changes too much

Or a combination of these.

Usually some limit to subdivision is also given to avoid taking forever.

Many systems that offer parametric plotting start with some changeable default setting for the heuristic params and step size. The user can adapt these if the curve is not "nice" enough or if it takes too long.

The problem is that there are always pathological curves that will defeat your method of drawing making it miss details or taking overly long.


Check out Bézier splines.

How to optimally plot parametric continuous curve?

0

精彩评论

暂无评论...
验证码 换一张
取 消