@pascal unfortunately it failed miserably
well you can implement that. For instance you retrieve the trimming boundary, create a point on the unmasked part, convert to Bezier and use the trim boundary to retrim and keep those parts where a point lays on top.
However, what I meant is modelling not coding.
Hello - feel free to post the model or send to firstname.lastname@example.org for a look.
thank you for your example. I am not sure if i interpret your pre-decrement
--nTotal and post-increment
nTotal++ correct in python, i get bezier curves with
ControlVertexCount == 6 and
Dimension = 3 with below code:
cp = System.Array.CreateInstance(Rhino.Geometry.Point4d, crv.Order) nTotal = 1 while nTotal < crv.Points.Count: nTotal -= 1 # PreDecrement for i in xrange(crv.Order): aControlPoint = crv.Points[nTotal] nTotal += 1 # PostIncrement w = aControlPoint.Weight cp[i] = Rhino.Geometry.Point4d(w * aControlPoint.Location.X, w * aControlPoint.Location.Y, w * aControlPoint.Location.Z, w ) result.Add(Rhino.Geometry.BezierCurve(cp))
ControlVertexCount equal 4 ?
crv.Order is equal to four, have you checked? The curve order is equal to 1+degree.
Thanks @menno, you are absolutely right. I was testing with a degree 5 curve, if i use degree 3 curves i get ControlVertexCount == 4. I’ve tried to make it recursive to further convert the results until all segments have 4 vertices, but this gives many short segments remaining with degree 5. Below input is a degree 5 curve with 8 control points, end points are in magenta:
I guess if i want to convert to bezier segments with 4 vertices each, i need to change the degree before ?
Yes, but that will change the curve. Why is it important to have 4 CPs?
Hi @menno, i try to make conversion from nurbs to 4 pt crv with tangent vectors and vice versa.
I see, in that case you should indeed work with degree-3 curves.
This would be my understanding on what needs to be done:
As a first step you’ll need to decompose an n-degree nurbs into its n-degree bezier elements. If n > 3 then you need to lower the degree afterwards. This however is a refit operation and likely has a deviation greater than your tolerance.
If n < 3 you can simply increase the degree and the curve will stay in shape. If n == 3 you are already done.
When refitting is required (n >3) you’ll need a good approximation algorithm. You can use Bezier Interpolation (-> inverse of the decasteljau algorithm) on the Greville points of your original Nurbs or you decompose the curve into multiple points and use a Linear Least Square approach to minimize the error. For most cases multiple curves have to be created. Especially when weights other than 1 are involved. Usually you should analyse for curvature extremes when it comes to spliting.
Thanks @TomTom for your explanation. Like with everything, i’ll try to follow the KISS* principle. Getting a small deviation is OK. Getting things out of Rhino is easier than getting things in. Just found that the curves i have to import have subcurves with 4 control vertices (anchors) and left/right tangent vectors with length…