PathMapper syntax

Hi,
I think (=hope) that eventually I will find a solution to this but I’m just posting it just in case somebody can help me get there faster:

I created a cube of cubes (5 by 5 by 5) but since it was created with box array it is a flat list. Since I want to map colours onto each cube, I need a tree of the form {5;5}(5) *where 5 is the paths/indexes count.

So, I have two (and a half) questions:

  1. how can I do it with pathmapper?
  2. can you use mathematical operations in pathmapper? for example: {A;B}(i)—> {sqrt(A);B}(i)
    2.1- If so, is there some syntax for higher order roots? (sqrt is “square root”, but is there a “cube root” syntax?)
    CubeRoot.gh (5.0 KB)
2 Likes

In case if you want to do partition list through Path mapper

CubeRoot_re.gh (11.5 KB)

2 Likes

Take the long way home and be a happy bunny (BTW: that’s 3 lines of code: your first DataTree C# mini def after 6 months from now). in our trade the long way is ALWAYS trhe short one.
.

Path mapper is static (meaning that he can’t adapt to dimension alterations that occur in 99% of real-life defs/cases). For the stuff that you are after I would suggest to avoid it when possible.

@HS_Kim
Wow, I didn’t know that was even possible using Path Mapper.

Kim,
As usual you delivered your magic!
but I didn’t make myself clear: I want to map rgb values to xyz values of the small cubes’ centers.

Here is my file as it is now, it’s chaotic (but that only reflects my understanding of the problem :slight_smile:)
I managed to create two trees of 125 values that should give a good result but it does not!

cube.gh (16.4 KB)

Spot on!
I didn’t know how to express it, as the concepts are still fuzzy in my head! nevertheless, since I cannot afford to stay non-productive until (and a very big “if”) I become a programming guru like you, I need to know these tools!

For the first 5 years the scope is to understand what’s happening and not to make it happen.

Here’s one way to do it using a single path mapper component:
{A;B}(i) → {i\pow(item_count,2/3); i\pow(item_count,1/3); i%pow(item_count,1/3)}
image
Thanks to your question, I learnt that the path mapper supports expression syntax! (Something which I don’t think the default GUI makes explicit)

P.S: You can see a list of all the operators that the syntax supports from the f:N ⇒ R button in the top right of the Expression Designer window.

Edit: using ^ operator is probably clearer, did not know about that either :open_mouth:

{A;B}(i) → {i\item_count^(2/3); i\item_count^(1/3); i%item_count^(1/3)}

3 Likes

@qythium happy to oblige :joy:
That’s where I started from, that’s where I found the “sqrt”. My question is: is this list exhaustive?

edit: just understood what “pow” is. so you can raise numbers to various powers.
still, I wonder is this list all there is? (not that it is little!!!)

Yes. But it doesn’t include operators such as *, ^, !, ² etc.

Forget about Path Mapper, it’s useless for robust code. Either create your data trees differently or use Partition.

CubeRoot
CubeRoot.gh (8.0 KB)

missing

When you put it that way, an entirely different approach suggests itself:


cube_colors_2018Feb18a.gh (11.4 KB)

5 Likes

I agree with @Joseph_Oster, a double partition in this case seems to make the most sense.

You’re the man!
thanks Joseph!
I was thinking about it in terms of making two trees coincidie in their 'architecture’
you simplified it a lot by just by inferencing each item’s coordinates!
I feel stupid now…

As long as you flatten the inputs to Bnd (Bounds), it doesn’t matter whether the geometry is partitioned or not.


cube_colors_2018Feb18b.gh (18.4 KB)

And instead of Volume ‘C’ (Centroid), which can be slow, you can use one of each cube’s vertices, or the Avr (Average) of each cube’s vertices.


cube_colors_2018Feb18c.gh (19.3 KB)

1 Like