Grasshopper

generative modeling for Rhino

# Creating a mathematical curve

Hey world,

- I was wondering, what is the simplest way of defining a curve based on a mathematical formula? Both F(t)=x(t, a1, a2...)+y(t, b1, b2...)+ z(t, c1, c2...) and F(x, a, b ,c...), and/or any other notation... where x, y and z are variables, and a,b,c... are constants but sliders, open for dynamic change. + Defining its interval.

- Another minor question; the intcrv box, it is by default a polynomial interpolation? In general, where can you get information on the underlying math behind the boxes?

- Is it possible to define the intervals on the sliders based on other sliders or inputs?

Many questions, but I have been trying to figure this out for quite some time now. I am truly grateful for all help on this matter! :) Maybe they will be of help to other engineers or architects out there...

Views: 718

### Replies to This Discussion

You can use one of two approaches:

1) Create a Grasshopper Definition using Maths Components or

or

2) Use the Fx components to calculate an expression with all your variables

Attachments:

Thank you for your help, it will sure be of help later in my project! However, both 1) and 2) give a discretized result, not a continuos result. How do I get exactly the curve I am after?

The points that you get from the methods above can be used to construct an IntCrv (Interpolated Curve). Is this what you mean?

Well, yes, but it would still be a discretizied method, and not an exact representation of the curve. The methods will by all means come in handy, but for where I am now in my project, I need (if possible) to use parametrized continuous curves. Do you know if it is possible to define in any way the function itself as a curve?

(from my second question in the initial discussion box): Do you know what is the default interpolation method used in the IntCrv-box, how to choose the method, and how in general to get information on the underlying math used in the boxes?

You have been of great help, I thank you so much for taking your time with this:)

There is no way to create an exact representation of the curve. For that you'd need a mathematical solver that is somehow able to understand what it is doing and therefore able to display tiny details. With Grasshopper, the best you can hope for is a curve that is accurate only at certain locations.

--

David Rutten

david@mcneel.com

Thank you, I will not spend more time investigating that.

I would assume that by understanding the interpolation methods used though, you will be able to achieve an exact representation for the selection of curves identical to any of the interpolation curves? Do you you know where I can get this information(ref. previous question)?

Interpolating the points may result in curves that have multiple y values for a single x value. Interpolation happens in 3D space and there's no constraint that would enforce a one-x-one-y rule.

You can use linear interpolation (i.e. polyline), or perhaps some form of cubic interpolation, but then you still need to convert that into a nurbs curve.

--

David Rutten

david@mcneel.com

Thank you for a well informed answer! :)

Do you know what is the default interpolation method for IntCrv, would that be cubic?

I assume then, that it would be possible to make an exact representation for curves, if you make an algorithm that dynamically defines the possition of the controlpoints for NURBS curves as a function of the parameteres in F(t, a1,...,b1,...,c1,...)= x(t, a1, a2...)+y(t, b1, b2...)+ z(t, c1, c2...) or F(x, a, b ,c...)?

Interpolate Curve can interpolate using all odd degrees (1, 3, 5, 7, 9 and 11). I don't know why even degrees are not supported, there may be good mathematical reasons for that.

Also note that fitting a nurbs curve through a set of N-dimensional points is not the same as cubic interpolation of a linear data-set.

It's certainly possible to fit a nurbs curve through a set of point with a one-x-one-y constraint, but Rhino does not have such a fitter in the SDK, so it needs to be written from scratch.

--

David Rutten

david@mcneel.com

With regard to the interpolation I don't know what method is used. I don't know of any way of finding out either. There may be something in the RhinoCommon SDK but I would imagine the actual maths is still not in the public domain.

A possible way might be to post a question on the v5.rhino3d.com website.

• View All