How would you extract expanded points from a spline?

How would you extract expanded points from a spline?

OceanHydroAU
Collaborator Collaborator
526 Views
1 Reply
Message 1 of 2

How would you extract expanded points from a spline?

OceanHydroAU
Collaborator
Collaborator

Lets say I have a spline made up of 10 points.  Can you think of a (preferably fast*) way to get 100+ points out of that?

 

I'm needing to convert any arbitrary input spline from fit-point to control-point.

 

I figure the "easiest" way would be to start by drawing the fit-point spline, then (using a subset (or superset) copy of the original (e.g. 10) input points) draw the control-point spline, and finally run some iterative code (hence needing fast*) to move the second set of points around until the two splines match one-another within some sensible tolerance.

 

Hence my question - is there some way to "rasterize" a spline, or some process that's not too slow that might let me get at those points that you can think of?  Or some other idea perhaps?

 

I did try asking the Fusion team for the exact spline code they're using, but they did not reply, and they've got some proprietary point weight adjustment going on that is not a pure cubic bspline - not to mention that bsplines don't specifically define end point behaviour anyhow.  This post of theirs comes tantalizingly close: https://www.autodesk.com/products/fusion-360/blog/sketch-control-point-splines-faq/ - but stops short of spelling out the detail we need.  (don't bother posting on that - it accepts comments, but they go to /dev/null)

0 Likes
527 Views
1 Reply
Reply (1)
Message 2 of 2

JesusFreke
Advocate
Advocate

If you have the sketch object, e.g. a SketchFittedSpline, the geometry field contains the NurbsCurve3D object that defines its geometry. And then you can use NurbsCurve3D.evaluator to "query" the geometry.

 

e.g. something like  (note: untested code :))

 

evaluator = spline.geometry.evaluator
start, end = evaluator.getParameterExtents()
step = (end-start)/100

points = []
param= start
while param < end:
    points.append(evaluator.getPointAtParameter(param))
    param += step