我写了这个简单的代码:
public static class Bezier
{
private static Vector2 GetInterpolatedPoint(Vector2 a, Vector2 b, float t)
{
return new Vector2(a.X * (1f - t) + b.X * t, a.Y * (1f - t) + b.Y * t);
}
public static Vector2 GetPoint(IList<Vector2> points, float t)
{
int initialCount = points.Count;
Vector2[] buf;
while (points.Count > 2)
{
buf = new Vector2[points.Count-1];
for (int i = 0; i < points.Count - 1; i++)
{
buf[i] = GetInterpolatedPoint(points[i], points[i + 1], t);
} …Run Code Online (Sandbox Code Playgroud)