View Full Version : divide curve equidistant straight line
I am trying to divide a curve in equidistant straight line segments. The code so far works but I would like to get better accuracy and speed.
This is the kind of accuracy I get so far, with spacing 1.0:
I can use python api if that helps but maybe there is a better basic approach to speed things up?
import maya.OpenMaya as om
import maya.cmds as mc
for t in range(kk):
for i in range(accur):
pointA=mc.pointOnCurve(curvename,top=True, pr=uValeStart, p=True )
pointB=mc.pointOnCurve(curvename,top=True, pr=uVale, p=True)
06-23-2012, 12:03 AM
how about simply using rebuildCurve?
Thx, but that wont help me, I want to enter a specific value for the segment length, and I dont need to preserve the last cv. Also the resulting points should be positioned on the original 3 degree curve.
when i use "rebuildCurve" to rebuild a 3 degree curve to a 1 degree curve i get the following:
- the distance between the segments are not equal
- the resulting points are not positioned on the original 3 degree curve
06-25-2012, 05:48 PM
would this work with chordlength parameterization,
uParam = (spacing/arclength);
get point at uParam
06-25-2012, 10:35 PM
Maybe you'll find here something:
thx, i have read through that post and unless i missed something, this is what your suggested code does: equal distance along u-param
i need equidistant straight Line distance so i can not use findParamAtLength.
the code from your post:
This is the kind of accuracy i get when i use the intersection node. For a curve in 3d i would need to intersect shperes, and maya does not have a command for nurbs surface - nurbs curve intersection. so you would have to extrude the curve temporarily and intersect surface with surface.
This is what my inefficient code from the first post does, i just want better accuracy and a bit more speed.
Export curve to Rhino rebuild with "DivideCurveEquidistant" export back to maya:
i understand maya is not a cad software, but it cant be that hard to create a tool that does this : http://wiki.mcneel.com/developer/sdksamples/dividecurvestraight
or maybe it is. i am not a math major ; )
06-26-2012, 12:05 PM
First of all, when using an iterative approach you needs to be aware of precision issue and decide for an acceptable tolerance value: you cant cut corner you have precision at the cost of speed .
Have you thought of using an IK spline solver with a joint chain?
Then on your code you use a command that in the background create then destroy a node to sample position on a curve: I would rather create once a pointOnCurveInfo and then bash it over and over to return the information I need. Same thing for your MVector create two outside the loop then modify its component
06-27-2012, 05:20 AM
1. I liked tonton's idea to create a 2-joint chain and attach them to the curve using ik spline handle.
2. As you suggested, extruding the curve with a circle profile with a vanishing radius, should approximate the curve with a tube. You'll get two points of intersection with a sphere, and you can average them.
3. You can always go hardcore. Each part of the nurbs curve consists of a certain degree polynomial (usually 3). Extract the polynomial coefficients from the nurbs knots and control points, and intersect this polynomial with a parametric sphere. If the polynomial degree isn't too high, you should have a closed form expression.
I am reading up on IK spline solver now, never used them before. ill post back the result :)
06-27-2012, 08:02 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.