I have two end points and two control points. I am using these points and this link. i have found a point on bezier curve. Now i would like to find angle at this point on bezier curve. Is there any formula?
-
What do you mean by an angle of a curve? An angle is formed by the intersection of two (differentiable) curves. What is you angle relative to? – Willie Wong Aug 27 '13 at 17:26
1 Answers
A cubic Bézier curve has an equation of the form $$ \mathbf P(t) = (1-t)^3\mathbf P_0 + 3t(1-t)^2\mathbf P_1 +3t^2(1-t)\mathbf P_2 + t^3\mathbf P_3 $$ When you say you want the "angle" of the curve, I suppose you mean the angle between the curve's tangent and the $x$-axis. If this is what you want, then here's how to get it:
If you differentiate the curve equation, you'll get $$ \mathbf P'(t) = (1-t)^2(\mathbf P_1 - \mathbf P_0) + 2t(1-t)(\mathbf P_2 - \mathbf P_1) + t^2(\mathbf P_3 - \mathbf P_2) $$ As you probably know, $\mathbf P'(t)$ is a vector that's in the direction of the tangent line of the curve at parameter value $t$. So, you just need to find the angle between this vector and the $x$-axis. If the vector is $(u,v)$, then the angle is $\arctan(v/u)$. If you're writing code, compute $\text{atan2}(v,u)$.

- 43,483
- 3
- 61
- 122