 # Curvature Graph - RhinoCommon

Hi,

Is there any rhinocommon method that could do the same display?
I was thinking that the values of vectors are osculating circle radius, but they are not.

@AndersDeleuran for bending rods and kangaroo you were displaying these graphs.
Could you share the code regarding this issue? Or is it display of second derivative of a curve?

I certainly can. Though mine was operating on bendy polylines of course, so I’m not sure if that would help much?

Edit: Here’s the method extracted from the larger bendy beam analysis class:

``````    def __calculateBendingRadii(self,polyline,roundDecimal,maxCircleRadius,minCircleRadius):

"""
Calculate the local bending radius for each vertex of a polyline.
"""

# Return lists
planes = []
circles = []

# Cast to polyline
if type(polyline) is not rc.Geometry.Polyline:
polyline = polyline.TryGetPolyline()

# Get polyline vertices and adjust list if closed
vertices = list(polyline)
if polyline.IsClosed:
del vertices[-1]

# Calculate the angle between each vertex and its neighbours
for i in range(len(vertices)):

# Get vertex and its neighbours
if i < len(vertices)-1:
vtL = vertices[i-1]
vt = vertices[i]
vtR = vertices[i+1]
else:
vtL = vertices[i-1]
vt = vertices[i]
vtR = vertices

# Average the vectors to the two neighbour vertices
vec1 = (vt - vtL)
vec2 = vt - vtR
vec1.Unitize()
vec2.Unitize()
vecLvr = -(vec1+vec2)/2
vecLvr.Unitize()

# Make a circle and a plane through the three vertices
crc = rc.Geometry.Circle(vtL,vt,vtR)
pl = rc.Geometry.Plane(vt,vec1,vec2)
circles.append(crc)

# Rotate the plane to align with the averaged vector
vecPA = rc.Geometry.Vector3d.VectorAngle(pl.YAxis,vecLvr)
pl.Rotate(vecPA,pl.ZAxis)
planes.append(pl)

if r > maxCircleRadius or r == 0:
crc = None

# Case for open curve (sets end radii/planes to same as neighbour)
if not polyline.IsClosed:

# Start vertex
planes.XAxis = planes.XAxis
planes.YAxis = planes.YAxis
planes.ZAxis = planes.ZAxis

# End vertex