Changeset View
Changeset View
Standalone View
Standalone View
curve_simplify.py
| Context not available. | |||||
| point = mathutils.Vector((0, 0)) | point = mathutils.Vector((0, 0)) | ||||
| for i, vert in enumerate(QVerts): | for i, vert in enumerate(QVerts): | ||||
| point += binom(order, i) * math.pow(t, i) * math.pow(1-t, order-i) * vert | point += binom(order, i) * t ** i * (1 - t) ** (order - i) * vert | ||||
| deriv = point | deriv = point | ||||
| return deriv | return deriv | ||||
| Context not available. | |||||
| # get curvature from first, second derivative | # get curvature from first, second derivative | ||||
| def getCurvature(deriv1, deriv2): | def getCurvature(deriv1, deriv2): | ||||
| if deriv1.length == 0: # in case of points in straight line | if deriv1.length == 0: # in case of points in straight line | ||||
| curvature = 0 | return 0 | ||||
| return curvature | return deriv1.cross(deriv2).length / deriv1.length ** 3 | ||||
| curvature = (deriv1.cross(deriv2)).length / math.pow(deriv1.length, 3) | |||||
| return curvature | |||||
| ######################################### | ######################################### | ||||
| #### Ramer-Douglas-Peucker algorithm #### | #### Ramer-Douglas-Peucker algorithm #### | ||||
| Context not available. | |||||