Use math.hypot()
Use a variable for number of tests
Optimized BezierCurve creation