I realized that I haven't released any snippets in a while so I figured while I was working on some interesting projects of my own that I would release one that I recently decided to write because I don't see the algorithm out there in C# very often. This snippet is useful for plotting preset paths in game development and can be used in many different styles. A race track, an enemy path in a 2D shooter, a plane's flight path, graph editing, so on and so forth. The implementation is simple as well. If you don't want to use the BezierPoint class that is provided then just replace it with the Point class from .NET framework when working with forms applications, or Vector2 from XNA Framework. I use my own class because I thought it would be fun. Anyways, hope you all enjoy and hope it helps some one out there.
Formula for a cubic Bezier curve:
^ = Exponent
_ = Subset
[x, y] = (1 - t)^3P_0 + 3(1 - t)^2tP_1 + 3(1 - t)t^2P_2 + t^3P_3
Algorithm Variables:
A = 3 * (P_1 - P_0)
B = 3 * (P_2 - P_1)
C = P_3 - P_0 - A - B
Algorithm (Current Point):
(C * t^3) + (B * t^2) + (A * t) + P_0
Have a great year,
Jamie