开发者

Curving from one point to another

I have tiles that are in random spots, and they wind up at x',y' (to make a nice 2d array) by doing :

Xt = (((X′-X)/T)*t)+X ,

Yt = (((Y′-Y)/T)*t)+Y

This works well, but it is linear. I'm looking for something curvier. A little bit like a parabola works. Basically instead of getting to X' in a straight line, I'm looking for an algorithm that will curve out and end up at X' and the amount of curvature is base on a variable.

Thanks

*EDIT I think Bezier curve look to be what I want, but I'm not sure how to impleme开发者_JS百科nt it. Could someone please explain the quadratic bezier formula. I'm also unsure what the 'E' - like symbol does. I think it relates to a range but I'm not sure, Thanks


You're looking for Bezier Curves, or some other similar parametric curve. These are programatically quite easy to code and have the advantage of being intuitively straightforward to manipulate. The best treatise I know of is in the classic book Mathematical Elements of Computer Graphics, but any textbook on computer graphics will probably include a basic introduction.


What you're looking for is a Catmul-Rom spline, it's a type of Hermite spline that passes though the control points. Bezier curves are not the way to go, they are difficult to control in this situation.


Have a look at this page about Perlin Noise, in particular the "Interpolation" section. The general idea is that instead of a linear transfer function over t in [0, 1], you can apply something to result in smoother curves. The "smoothest" noise is a cos(t) function, but cubic or quintic polynomials can be used to approximate a cosine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜