Grasshopper

algorithmic modeling for Rhino

I am no programmer, I'm not even a mathematician, so implementing this as a custom component is most likely outside of my reach. A lack of understanding and expertise aside, I still see the amazing potential for a general component that performs Automatic Differentiation. From the research that I have done on the subject, AD appears to be the most accurate and fastest method of computationally and recursively deriving functions.

I've found a C++ library that is unlicensed and freely available that performs AD. I can't attest to it's accuracy, reliability or anything, but it is at least a great place to start for someone with the skills to put it in place, which I am just short of BEGGING someone to do!

Here's a link to the files and a good explanation of what the library does.

Here is also the Wikipedia article on AD

Views: 1277

Attachments:

Replies to This Discussion

Hi Shawn,

can you explain a bit more how this would be used inside Grasshopper? I mean both the hands on usage (what would the inputs/outputs be of an AD component?) and conceptual usage (what's it for?)

--
David Rutten
david@mcneel.com
Poprad, Slovakia
You might want to look at Mathematica's .Net/Link, which you might find easier to connect to GH than a C++ library.
But I too am curious what you want to use this for?
Again, I'm not an expert in math or programming, so forgive me if I make some really dumb assertions here. Your question, coupled with Daniel's made me wonder if I understand what this is and/or the current limitations of GH since I see you two in particular as having a command mastery of all this stuff. I had thought its usefulness would be apparent. So bear with me as I open my mouth and expose the fool that I am. =/

The project I am currently working on relates a 2D set of curves with additional constraints to derive a 3D space curve that defines the crease of a curved fold of a developable surface. The equations for relating the 2D geometry to the 3D space curve and resultant surfaces require 1st, 2nd, 3rd and 4th derivatives of the functions of the input curves. The goal of this project is to produce an algorithmic solution to a range of geometric inputs using GH. I very well could be wrong, but I don't see a way (other than a custom component that applies the derivatives of the functions) of doing this in GH.

I guess there are a couple of ways it could be implemented. I think the ideal would be to integrate it into the Expression Editor so AD could be added to any function component, but I can see value in doing it both ways. It would basically add the ability to compute Derivatives within the Function components.

As a separate component ...

Inputs:
F - Function
.....a) String Input or Expression Editor
.....b) Input Geometry - uses the function of input geometry
d - Degree of Derivation (the number of recursions)
x - With respect to
a - Optional "at"

Outputs
f'(x) - String output of df/dx (I don't think the lib I linked to will do this)
f'(a) - Numeric output of df/dx at a

Currently many of the algorithms used in GH found in components use derivatives of a function to produce their results. I think of curvature or curve frames as an example. With AD you shouldn't need to write a curvature component if you know the derivative formula to use. This would open up more functionality and freedom to users without programming experience to solve nearly any problem (hyperbole) in GH. The next logical step would be adding integrals. AD may also provide a framework for authors of custom components to use simple formulaic inputs in an automated engine to produce (what I think must be) the hardest part of programming the components.

If you or anyone else have suggestions as to how I may otherwise tackle my problem, I am definitely listening!

@Daniel - I have considered using Mathematica for the project as well as Catia, but I am already knee deep in GH and would greatly prefer to use David's wonderful piece of software. The .Net/Link software requires Mathematica be installed, so I'd still have to get a copy, ... then I might as well use it instead of GH.
If you already have an equation for the curve then surely you can just differentiate that manually or use a tool like Alpha?
While it might be a nice luxury, I don't really see how having the ability to do that directly within GH would be any huge advantage, as functions/expressions are something you input, and you always have to change them manually anyway.
If you don't have an equation and want the gradient of an arbitrarily drawn planar curve you could also do that geometrically - by taking the tangent vector at x, then divide the y-component by the x-component.
Anyway, this is all rather vague without a specific example to refer to. What are the equations you are working with and where do they come from ?
Thanks for your reply. I won't typically have the equation for the curves to start with as they will be supplied at 'runtime.' As to geometrically solving for the derivative, can't that only be done once? Once you have a line, geometrically you will only ever get a line tangent to another line after that.

As to the specifics of my project, here's the paper that I'm starting from ...

PDF

The example in the paper is the most basic shape based on a cylinder, whereas the ones I am working on will be of more complex tube shapes, but I need to get this basic design working first.
What do you mean supplied at runtime? supplied by another program ?

You can geometrically find the derivative as many times as you want.

To be more explicit - you take y/x of the tangent vector to your original curve at x as the y-value of the new point at x. You can then interpolate these points to get a new curve(1st derivative), then repeat using that curve to get the 2nd derivative and so on.

Attached is a simple example.

But anyway, I suspect this might not actually help you much. A glance at that paper suggests to me that even with a way to find derivatives, you would still need a fairly good mathematical understanding to be able to apply it. Perhaps approaching the entire problem geometrically would be easier ?
Attachments:
The GH file will likely be used on a wide range of geometric inputs by people who have no understanding of the underlying concepts. So by at "runtime" I mean at the point of use after the definition is complete.

Thanks for your clarification on solving derivatives geometrically. I feel like I should have been able to see that intuitively. My understanding of Calculus is based on HS Calculus taken almost 20 years ago so needless to say much of my math skills are rusted over, but I usually understand the concepts well enough to figure out what is going on, although perhaps not well enough to know where to go next. I've been wading through this problem for some time and had to learn all of the differential geometry concepts and terminology from scratch trying to piece things together. What took me weeks to figure out I was able to clearly explain to someone else in five minutes. I am determined to solve this problem and I believe I am very close to using GH to do it. An AD component still seems like an easier way to get there. =P

Thanks for your help.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service