How to estimate the slope of polyline at multiple points

Hello everyone,

I have a polyline shown in the image and 10 points are available on that curve. Is there any possible way to get the value of the slope at those 10 points?

Is the curve 2D or 3D?

Do you want to obtain the slope at each point:

Using only Rhino commands?

Using Grasshopper?

???

Hi Soumik - - the slope can be got from the tangent vector at the points - it is awkward in plain Rhino but a script can find these - here is a python that may do what you need.

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

def MarkSlopeAtPoints():
    tol = sc.doc.ModelAbsoluteTolerance
    
    id = rs.GetObject("Select a curve", 4, preselect=True)
    if not id:
        return
        
    crv= rs.coercecurve(id)
    
    ptIds = rs.GetObjects("Select the points", 1)
    if not ptIds:
        return
        
    pts = rs.coerce3dpointlist(ptIds)
    
    for pt in pts:
        rc, par = crv.ClosestPoint(pt)
        if rc:
            if crv.PointAt(par).DistanceTo(pt) < tol:
                tan = crv.TangentAt(par)
                s = round(tan.Y/tan.X, 3)
                rs.AddTextDot(str(s), pt)
                
if __name__ == '__main__':
    MarkSlopeAtPoints()

-Pascal

1 Like

The curve is a 2D plane and I am looking to get the value using any Rhino command.

Create a line tangent to the curve at a point
Point Osnap on
Line command
Select Tangent option
For Start of line select PointOnCurve option
Select the curve at a point
For End of line select FromFirstPoint
Move cursor and enter to creat the tangent line.

Angle of tangent line from horizontal
Near Osnap on
Angle command
Start of first line - click on the tangent line
End of first line - click on the tangent line
Start of second line - click anywhere
If Ortho is not on hold down Shift key and move cursor to side for horizontal line
If Ortho is on then move cursor to side for horizontal line
Result is the angle of the curve tangent from horizontal

For slope as rise/run use a calculator to obtain tangent of the angle. Then multiply the tangent by the run to obtain the run.

For slope as a percent grade use a calculator to obtain tangent of the angle. Then multiply the tangent by the 100 to obtain the percent grade.

1 Like