Curve mathemathics: curve + gradient derivative * constant

Hi there,
I’m looking into finding information about OpenNurbs access with python scripting on mac.
Basically what i’d have to do is this:
Given a curve A, i’d like to generate another curve B which is generated according to the following formula:

Curve B = Curve A + gradient(X,Y,Z) * constant

My current and idiotic script does the following:
It divides the curve in a lot of small points and offsets these points by the derivative,
but this gets computationally very messy and generates messy curves too.

``````import rhinoscriptsyntax as rs
import Rhino
import scriptcontext
import System.Guid

class TanLines:
def __init__ (self, INcurve, INdivideBy, INradius):
self.curve = INcurve
self.divideBy = float(INdivideBy)

def tanPoints(self):
doms = rs.CurveDomain(self.curve)
minDom = doms[0]
maxDom = doms[1]
points = Rhino.Collections.Point3dList(30)
lengthCurve = rs.CurveLength(self.curve)
self.numOfDivs = (lengthCurve/self.divideBy)

for i in range(0, int(self.numOfDivs)):
if i > 1:
paramNext = ((maxDom-minDom)/self.numOfDivs) * (1+i)
if i == 1:
param = ((maxDom-minDom)/self.numOfDivs) * (i)
param = (maxDom-minDom)/self.numOfDivs * i

pt = rs.EvaluateCurve(self.curve,  param)
tan = rs.CurveTangent(self.curve, param)
if i > 1:
tanNext = rs.CurveTangent(self.curve, paramNext)

if i == 0:
tan = rs.VectorScale(rs.CurveTangent(self.curve, param), -10)
elif i == self.numOfDivs-1:
tan = rs.VectorScale(rs.CurveTangent(self.curve, param), 10)
else:

if (i > 1):
if (rs.IsVectorParallelTo(tan, tanNext) == 1):
else:

nc = Rhino.Geometry.NurbsCurve.Create(False, 3, points)
rc = Rhino.Commands.Result.Failure
if nc and nc.IsValid:
Perhaps you should just create a curve thru your calculated points. Use `rs.AddInterpCurve` for this. Check the help file for details.