# calculated tangent slope is not the same as start and end tangent slope of bezier curve

I have calculated the tangent for start point and end point of cubic bezier curve, but the calculated slope and coordinates of tangents are not continuous to the tangent lines (segment $P_0 P_1$ and $P_2 P_3$), as shown in this picture. $m_{start}$ and $m_{end}$ from calculated tangent (blue lines in picture) and tangents which are the subtraction of control points are different. Is there something wrong in my calculation?

The curve equation,

$C(t) = (1-t)^3P_0 + 3t(1-t)^2P_1+3t^2(1-t)P_2 + t^3P_3$

Control points are:

$$P_0 = (14.89, 118.65)$$ $$P_1 = (40.40, 130.86)$$ $$P_2 = (65.91, 143.08)$$ $$P_3 = (71.44, 124.94)$$

Derivative of curve, $$C'(t) = -3(1-t)^2 P_0 + \left[3(1-t)^2 -6t(1-t)\right]P_1 + \left[6t(1-t)-3t^2\right]P_2 + 3t^2P_3$$

Substituting the coordinate value of control points in C'(t), $$x = -59.94t^2 + 76.53$$ $$y = -91.02t^2 - 0.06t + 36.66$$

Tangent at $t$: $$T(t) = \frac {C'(t)} {\vert C'(t) \vert} = \frac {C'(t)_x, C'(t)_y} {\sqrt {\left[C'(t)_x\right]^2 + \left[C'(t)_y\right]^2}}$$

Tangent at end point, $t=1$: $$T(1)_x = 0.29$$ $$T(1)_y = -0.95$$

Tangent at start point, $t = 0$: $$T(0)_x = 0.9$$ $$T(0)_y = -0.43$$

Slope equation: $$m = \frac {y-y_0} {x-x_0}$$

Slope for end tangent, t = 1: $$m_{end} = \frac {P_{3y}-T(1)_y}{P_{3x}-T(1)_x} = 1.77$$

Slope for start tangent, t = 0: $$m_{start} = \frac {P_{0y}-T(0)_y}{P_{0x}-T(0)_x} = 8.45$$

slope for segment $P_0P_1$,
$$m_{start} = \frac {P_{0y}-P_{1y}}{P_{0x}-P_{1x}} = 0.47$$

slope for segment $P_2P_3$,
$$m_{end} = \frac {P_{2y}-P_{3y}}{P_{2x}-P_{3x}} = -3.28$$

Tangent at $t=0$ should be $(0.902, 0.4320)$.
From $T(0)$ and $T(1)$, we can compute the slope as $0.432/0.902=0.478$ at $t=0$ and $-0.95/0.29=-3.27$, which matches your computation of slopes from $P_0P_1$ and $P_2P_3$
• Tangent at t = 0 is typo error. For cubic bezier curve, $P_0P_1$ and $P_2P_3$ are tangent to start and end point and calculated T(1) and T(0) are supposed to be in a straight line to $P_0P_1$ and $P_2P_3$, but they are not. I have plotted T(1) and T(0) $T_1$ and $T_2$ here. – Toat Nov 11 '16 at 5:41