Wrong tangential directions for cubic bezier curve
Using what Rahul kindly suggested in the comments, I realised that my tangent can be rotated in the opposite direction for two cases:


if dy/dt and dx/dt are both negative, yet dy/dx ends up being positive
if dy/dt is negative and dx/dt is positive, so the overall dy/dx is negative


This is because my angle calculation, which is done by float angle = atan(dydx) * 180/M_PI; will only calculate acute angles from the horizontal, and hence miss out the opposite cases.

Thanks a bunch!