У меня есть следующий код для вычисления точек между четырьмя контрольными точками для генерации кривой камуфляжа:
CGPoint interpolatedPosition(CGPoint p0, CGPoint p1, CGPoint p2, CGPoint p3, float t)
{
float t3 = t * t * t;
float t2 = t * t;
float f1 = -0.5 * t3 + t2 - 0.5 * t;
float f2 = 1.5 * t3 - 2.5 * t2 + 1.0;
float f3 = -1.5 * t3 + 2.0 * t2 + 0.5 * t;
float f4 = 0.5 * t3 - 0.5 * t2;
float x = p0.x * f1 + p1.x * f2 + p2.x * f3 + p3.x * f4;
float y = p0.y * f1 + p1.y * f2 + p2.y * f3 + p3.y * f4;
return CGPointMake(x, y);
}
Это отлично работает, но я хочу создать что-то, что, на мой взгляд, называется параметризацией центростремительной. Это означает, что кривая не будет иметь точек возврата и самопересечений. Если я перемещу одну контрольную точку, действительно близкую к другой, кривая должна стать "меньшей". У меня есть глаза, с которыми я пытаюсь найти способ сделать это. Кто-нибудь знает, как это сделать?