Spread to vectors and vectors to spread

Hello, is there any ressources or help patch to learn how to deal with converting-extracting vectors from spread and SpreadVector3>>> form ?

I m currently working on a leap patch, and fighting with this data form outgoing of my foreach loop needed to deal with [hands] node
Thank you

Let me make the comparison between beta and gamma, since this is what you were asking in your other post.

In beta there was no difference between a Vector3 and a spread of three floats. There was also no difference between a single value and a spread of one slice. This is not true in VL, you have to see a spread not only as a loose collection of values, but rather as a value of its own (which in turns contains values).

image

So let’s say you have this Spread<Spread<Vector3>>, and you want to retrieve the vector that is equal to [13,14,15]

image

Consider the outermost spread : the vector you’re interested in is in the third slice, the one that in turns contains three slices. We’re considering spreads as a thing of their own, they do have a structure. Beta did not have this, so we ended up with this binsize hell, but this is not the case anymore in gamma.

So we would first use GetSlice to retrieve the third slice of the out-most spread, and now we’re left with a one-dimensional spread where we can also GetSlice to get the second slice to have just a Vector3.

image

Now I’m not sure how that explanation applies to your Leap problem since I don’t know exactly what you were trying to achieve there, but as far as retrieving a single item from a Spread<Spread<T>>, that should help.

1 Like

I see in your screenshot that you are filtering slices based on some boolean value.

If that’s what you’re after, then I would suggest watching this video that explains how the ForEach loop works, and pay attention to the part when it explains the Keep pin :

Basically, if you feed a boolean to this Keep pin, only the iterations where this pin is set to true would be outputted from the region. This means you won’t have to use all those S+H nodes.

EDIT : maybe what scares you is that things seem to be more “verbose” in gamma, because you have all those regions and have to “manually” iterate over spreads. In beta it was “easier” because you could connect spreads (almost) anywhere, and it would implicitly iterate over them. As far as I’m concerned I think the behavior we have in gamma is way less confusing because it does not do some magic implicit logic and lets you control your iterations way more precisely and in a more granular way.

1 Like

I assume that the problem lies in the filtering of values. It is better to provide an example or a screenshot.

@sebescudie Thanks a lot its great !
Your getslice demonstration is very clear ! I will take a true complete time thruth all sources you sended to me, and i thank you !

@digitalwannabe gave me the key for my problem with the Leap, outgoing from the foreach loop the spread of spread:
Using Getslice or FirstOrDefault enables me to connect directely Split[Hand]node to Hands node. Getting fingers positions separatly is now possible with GetItem. Seems the LeapOrion library is written as a mutablelist.

And that was also a part of my problem, as i didnt know any of this. For me it was supposed to be a getslicing.

Have a beautiful day and thank you

I strongly recommend that you familiarise yourself with the concept of Process Nodes. Also Operation Nodes. It would help you a lot in optimising your patch. Roughly speaking, it would be easier for you to parse the data and rebuild it into something more convenient in a separate node relative to each hand object.

But it sounds like you have the most basic “how to use collections” type questions right now. I’d like to point out that you have a wonderful world of mutable and non-mutable collections ahead of you))

1 Like

for completeness: there are also VectorsToValues and ValuesToVectors nodes, see help: HowTo Convert between spreads of vectors and values

thank you @joreg joreg