Dear Rhinos,
Hope all is fine by your side. I would like to ask if there is any way to find the most curved part of a curve by using vector (angle maybe?) or other like in the picture below, so I can split into two kind of curves ? Any suggestion ? Thank you very much
Hi,
I hope this comes handy
9_InflectionPoints.gh (15.9 KB)
Otherwise you could integrate a custom py script
def find_inflection_points(curve):
"""Find the inflection points of a curve."""
# Parameterize the curve
curve.Domain = Rhino.Geometry.Interval(0, 1)
# Initialize the list of inflection points and their curvatures
inflection_points = []
curvatures = []
# Sample the curve at a number of points
num_samples = 1000
for i in range(num_samples):
t = i / num_samples
# Calculate the curvature vector at the current point
curvature = curve.CurvatureAt(t)
if curvature is None:
continue
# If this is the first sample, save the sign of the curvature and continue
if i == 0:
previous_curvature_sign = curvature.Z > 0
continue
# Determine the sign of the current curvature
current_curvature_sign = curvature.Z > 0
# If the sign of the curvature has changed, add the previous point to the list of inflection points
if current_curvature_sign != previous_curvature_sign:
inflection_points.append(curve.PointAt((i - 1) / num_samples))
curvatures.append(curvature.Length)
# Update the sign of the curvature
previous_curvature_sign = current_curvature_sign
return inflection_points, curvatures
....
inflection_points, curvatures = find_inflection_points(curve)
if inflection_points.Count >0 :
# Find the inflection point with the most variance
max_variance_index = curvatures.index(max(curvatures))
max_variance_point = inflection_points[max_variance_index]
# Add a dot at the inflection point with the most variance
dot = Rhino.Geometry.TextDot("Max Variance Inflection Point", max_variance_point)
dot_id=scriptcontext.doc.Objects.AddTextDot(dot)
....
Hi. many thanks for your alternative about “Derivatives”. Something I missed. However, how can we adjust the minima/maxima ? Because it seems be a little bit far away. Or it depends of the curve ?