Hi everyone,

I want to find all peaks of curve as points (the points where the curve peaks as shown on the image). Is there a way to do that in dynamo or I’m just hoping for too much?

Hi everyone,

I want to find all peaks of curve as points (the points where the curve peaks as shown on the image). Is there a way to do that in dynamo or I’m just hoping for too much?

You might find this interesting:

http://www.revitapidocs.com/2015/93092a44-85f1-15be-a618-817c763f8994.htm

1 Like

@fluffyhugger - which peaks would you want to find in these two shapes?

(sorry for the poor quality but I’ve got limited resources as I’m stranded at an airport at the moment)

1 Like

@jacob.small first, thank you for the effort seeing you’re busy but still trying to help!

The first shape.

Can you mark where you think they should be as you did in your original image though? The answer to that will impact the recommendation for how to proceed. It could be as simple as getting the tangent angle at each control point along the curve and comparing that to the prior and next angle, or finding the midpoint of each, or finding… well anything really.

The markings that I’ve made are more or less arbitrary. There are where I think the curve peaks.

The point is, and correct me if I’m wrong in mine description, that a curve is a collection of arcs and straight lines that fluently connected to each other. I want to know where the midpoints of the arcs are and actually where the endpoints of the straight lines are. But that second one has less priority right now.

So… a nurbs curve actually has infinite radii and tangencies based on how they are modeled, so technically it’s not possible to grab any midpoint. You could try to approximate a polycurve from the nurbs cuve, but data will be lost (maybe that’s a good thing in your case - hard to say as I don’t have an accurate starting point).

If you have a polycurve already, Polycurve.Curves & Curve.PointAtParameter 0.5 should do the trick.

A quick implementation of this on a spline, without calculating the local Min and Max of the function and other techniques, could be finding the closest point on the spline to the control cage points.

Probably is not mathematically perfect though.

1 Like

@jacob.small Theoretically, you’re right but i don’t need so many points (see image), i just need a few that are at the peaks.

@mikael_deity That’s true, but i don’t have the control points… Is there a way to derive them?

NurbsCurve control points can be found by using the aptly named node NurbsCurve.ControlPoints

@mikael_deity’s method sounds the best in the case where you might not want to convert a nurbscurve into a polycurve. I don’t know if it is possible to tell which direction the control point is in relation to its corresponding point on the curve is though, which would be a problem if the nurbscurve curves back towards itself (see picture, p3 and p4)

This method is good but it doesn’t yield the same curve… Furthermore if I try rebuilding the curve by just using th control points, it’s deviates even more… why…

@fluffyhugger Why are you doing this part of the script? you got the points at peaks. Can you explain are you trying to accomplish after you get the points?

If you rebuild a NurbsCurve through points extracted from a NurbsCurve, it will not give you the same curve. Have a look:

https://en.wikipedia.org/wiki/Spline_(mathematics)

https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline

It’s an interpolation between points with very defined rules.

@Mark.Ackerley watch out, your script is circular!

@kennyb6 Good point! I think this can be solved by splitting the curve by its knots.

What do you think?

NurbsCurvePeaks.dyn (56.0 KB)

3 Likes

Hey @mikael_deity

Nice graph TBH I’m not exactly sure what the OP is looking to do with these points It sounded like they wanted to recreate a nurbs curve, but presumably I misunderstood.

Thanks for the heads up. How do you mean circular? It explains abstract concepts without requiring wikipedia and illustrates them with Dynamo nodes.

I’d prefer to think of it as Newton’s experiment with prisms to demonstrate the structure of light

@Mark.Ackerley Thanks!

I meant that you were building a NurbsCurve from the properties… of a NurbsCurve!

If your aim was to explain the components of the curve to OP, then ignore my comment. Maybe a couple of lines together with your graph would have helped a bit more to clarify to OP (and myself).

I sent Wiki links because it’s important to study a bit of general concepts of geometry before going deep into computational matters!

1 Like

@mikael_deity @Mark.Ackerley @kennyb6 @jacob.small

what I’m trying to achieve is indeed replicating nurbs-curve as accurate as possible with as less as possible points. But from what I understand it’s actually not possible. The question is how accurate can I do it.

@mikael_deity

With only points that are the closest to the control points I can’t get accurate representation of the original nurbs. But with extra points in between I get a better approximation. The point is to get there with as less points as possible.

So there is going to be a relationship between all the inputs to the Nurbs curve…

I guess that if you want to reduce the number of control points, you need to compensate by moving the other points and adjusting the values of the degree etc. The amount that these change would presumably be related to their proximity to the removed point…

Presumably if your Nurbs are similar this has a chance of working? Otherwise the proximity could look quite random…

Hope that helps,

Mark

Ok, your original question was to find the peaks of the curve, and that’s what we aimed to achieve.

Worth having a look at Curve.Simplify, might help you.

1 Like

Why replicate? It’s lready there and usable. Am I missing something?