Grasshopper

algorithmic modeling for Rhino

Does anyone understands Catmull-Rom interpolation?

I've managed to do an implementation of Catmull-Rom splines using Bezier Spans, even though I don't completly understand the math involved.

My objective was to be able to constrain the curve to avoid the overshooting that the native interpolate occasionally does. I was able to constrain the max distance from the curve to the control polygon controlling the length of the vectors.

The problem is I don't really know how to resolve the start and end segments. I put together a hack but I'm a bit unsure about it.

Also I would like some critique on the definition itself.

Views: 2722

Attachments:

Replies to This Discussion

Anyway get the promised Plan B ... just for the record and/or fun (but I can't see any noticeable visual difference).

Attachments:

And just for fun ... get these freaky thingies as well.

For the weird fit cubic def my good friend Tom Jankowski did the classic least squares part.

For the classic Douglas/Reumann reductions play with the also classic (these days) Butterworth approach as well.

Attachments:

those were definitely freaky :P, but interesting stuff!

anyway, thank you for your help, here is the finished thing.

I added a few options for the "cheats" / end segments, and a few examples for the rest, (constraining part, parametrizations).

Check it out.

Attachments:

... Check it out...

Mama mia > I'm not that brave you know > Ctrl+Alt+Defeat.

Ctrl+Alt+Defeat.

hahaha, now you know how I feel looking at the C# code you sent me.

It started much simpler...

The hardest part was making sure it worked with trees..

Hi, I'm "translating" this component to C# (and learning to code at the same time). I've managed to get it working (at least the core code) but i have a small problem with the paths of the outputs. If I supply the component with a tree it'll add a 0 to the paths of certain branches of the outputs.

for example: input is {0;2} output is {0;2;0} 

the output is a list of points.

Do you know what I'm doing wrong?

Attachments:

Restart from node 0 (depth of answers etc etc).

Firstly the points is declared as List whilst is a Tree:

Stuff corrected.

BTW: In order to receive further assistance (and much more) > you must sign the paper (that's the short version ... but who cares reading the fine prints?).

Moral: just sign.

Attachments:

Ok, I accidentally erased my previous reply...

I've updated to file for tree acess, but that brings more problems, in the meantime i noticed that the behaviour i was getting with the added 0s happens with normal grasshopper components so I guess it's not an issue...

Anyway in the end it was good because I learned a lot about working with trees.

I've discovered a bug (I think) with the DataTree.Insert method - it replaces the item on that index instead of working like the List.Insert. It took me a while to figure that out. Luckily using .Branch(path).Insert worked.

Anyway here's the latest working file if you are interested.

Thanks for all the help.

Attachments:

Well ...

1. Why use var for such an "explicit" thingy like Lists/Trees?

2. If you want to get rid of null/O and the likes you need a better control on what you write on your referenced Trees.

For instance this is a bit oxymoron ( if there's no points why bother making the branch? [to put what on that? maybe bananas?]) ?

3. The 2nd C# needs rewriting by the book (Main should use less lines than an A4 and/or what you can see in your screen editor without scrolling). PS: Use public Methods for the variables and avoid passing a million of things in the Methods on duty (PS: this is quite handy in recursively working stuff) .

Bravo (but keep walking the walk). 

Thanks a lot for the review. Some follow up questions:

1. "Why use var" - No reason really just lazyness, is there a reason why I shoudn´t? Is it bad practice to use var in situations you don´t really need to?

2. "if there's no points why bother making the branch?" - It seems the default behaviour of grasshopper components is to keep empty branches, I just did the same. Not sure if there are situations where it would make a difference, but it just seemed the right thing to do.

3. "The 2nd C#" - are you talking about the v.01 tree? because if so the v.02 is already a rewrite with a very concise Main.

    "Main should use less lines than an A4 and/or what you can see in your screen editor without scrolling thanks for the tip" - thanks for this tip will do that from now on

   "Use public Methods for the variables" - could you explain this a little better? what's the difference in the grasshopper script component of using public vs private?

thanks again

Well ...

1. If we have a List/Tree is a List/Tree. If on the other hand you are in a hurry indeed using,say, var rg = Curve.PlanarClosedCurveRalationship (...) instead of RegionContainment rg = ... could(?) make(?) some(?) sense. But remember: in programming sooner or later you pay for the laziness.

2. Empty branches on complex code require additional questions/checks. If at making time you can avoid/manage them ... well ... avoid/manage them (unproved Theorem N666.6 + LOUC (Law of unintended consequences)).

3. V2 is always the better thing.

Methods with public variables:

Well imagine a recursion:

public void DoSomething(a,b,c,d,..., ref y, ref z) that calls itself. Firstly using void (and ref) is far more elegant than declaring the type (and using out for y,z). Secondly if there's a myriad of variables (with long names) you can skip including them in the DoSomething (twice since is recursion) and just use them. The locomotive syndrome you know.   

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service