Calculating a new list from two lists?

cubehexagonal's Avatar

cubehexagonal

24 Oct, 2021 09:31 PM

Is it posible to combine two lists with a calculation? For example:

List A:
1, 2, 3

List B:
3, 2, 1

List C (output of the node I need):
4, 4, 4

Ist this possible? Which node do I need?

  1. 1 Posted by cubehexagonal on 24 Oct, 2021 09:49 PM

    cubehexagonal's Avatar

    I want to add two lists of XY coordinates.

    First X from list A is added with first X from list B.
    First Y from list A is added ith first Y from list B.

    etc.

  2. Support Staff 2 Posted by john on 24 Oct, 2021 09:54 PM

    john's Avatar

    Yes, this is easy.

    Simply combine the two lists with an ADD node.

    See screenshot. List A contains 1, 2, 3. List B contains 3, 2, 1. I simply feed them into an add node and the output is 4, 4, 4.

    (I added an integer node because the list and add nodes output floating point numbers which show as n.0. The integer node turns them into integers (which may or may not be necessary).

    There is a subtlety to how this works. The add node is configured to take items from a list one at a time. Each time an item from list A and an item from list B arrive at the node it outputs the sum of these two items.

    So in this case the node fires 3 times. The first time it outputs 1 + 3 = 4. The second time it outputs 2 + 2 = 4. The third time it outputs 3 + 1 = 4. The result is a list containing three 4s.

    Please let me know if you have any other questions. Happy NodeBoxing!

    John

  3. 3 Posted by cubehexagonal on 24 Oct, 2021 10:03 PM

    cubehexagonal's Avatar

    Thanks!

    Sorry, I found out it works with the add node two minutes before seeing your answer. ^^'

    Maybe it didn't worked well at first because I didn't split the list into X and Y.

  4. Support Staff 4 Posted by john on 24 Oct, 2021 10:06 PM

    john's Avatar

    Your followup question arrived just as I posted my answer. But I think my answer also works for your followup.

    You can separate the Xs and Ys from each list of points using a lookup node, then use the Add node to combine the Xs from A and B and the Ys from A and B. Then turn these two lists back into points by simply feeding the two lists into a point node.

    If this is unclear let me know and I will make an example file for you.

    John

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

30 Nov, 2021 04:00 AM
27 Oct, 2021 08:07 PM
24 Oct, 2021 10:06 PM
21 Oct, 2021 07:54 PM
22 Sep, 2021 02:21 PM

 

21 Sep, 2021 06:32 AM
11 Sep, 2021 03:55 AM
10 Sep, 2021 04:25 AM
06 Sep, 2021 07:06 PM
20 Aug, 2021 03:27 PM
18 Aug, 2021 11:31 AM