This section contains nodes to create, edit, and manipulate arrays.

In programming, an array is a data structure consisting of a collection of elements (values or variables), each identified by at least one array index or key. More information.


Characteristics


In Modulo Kinetic, an array is composed of a series of organised values that is easier to understand when displayed as a table using the Listing node.

Throughout this documentation the following terminology is applied :

  • An array is composed of Items. Each Item corresponds to one full line in the table.
  • The first line in the table always represents the Properties of the array. These will define the columns of the table.
  • For every property, an item will hold a Value.
  • The items are organised using an Index, an invisible token that always starts at 0 and increments by 1 for every item in the array.
  • Each item can be referenced by its ID, a visible token identifying an item. The ID does not necessarily start at 0 and can increment in various ways.

Difference between Index and ID :

The index will always be an ordered list, starting at 0 for the first item and incrementing by 1 for every item.
It is dynamically adjusted to the number of items present in the array. An item is attributed to an index depending on where it is present in the array, but the index for an item can change over time.
For example, if there are five items in the array, the index will range from 0 to 4. If that same array drops two items, the index will range from 0 to 2, and the three remaining items that were not dropped may or may not have had their index changed, depending on their order in the array before the items were dropped.

The ID is not necessarily ordered, and depends on whatever generated the array, whether it’s a sensor or other nodes.
In the case of some sensors, as with the Leap Motion used in this example, the ID corresponds to the fingers as they are detected by the sensor. For every item the ID will always remain the same for as long as they exist in the array.
For example, if the fingers with ID 0 and 1 are dropped because they are not detected anymore but the other fingers still are, they are moved up in the array and their index change but not their IDs.


Array nodes


  • Add Item : Add an item in an array or create an array
  • Remove Item : Remove an item from an array
  • Grab : Grabs the position of an object to offset it according to tracked data so it does not move when the tracked data suddenly changes
  • Merge Items : Merge two arrays into a single array
  • Merge Properties : Merge the properties of two arrays together and select which items from the second merge with the first
  • Merge Tracking 2D : Merge two arrays of 2D tracking data with built-in Kalman filter to merge items in the array
  • Transition : Apply IN/OUT transition to array data
  • Remap : Modify individual data inside an array
  • Items Selector : Extract a section of an array using Index or ID
  • Trigger Area : Triggers booleans when values from an array enter a predefined area
  • Trigger Area 3D Scene : Create trigger zones in the 3D Scene from a camera’s point of view
  • CSV to Array : Converts CSV data into an array
  • Array to CSV : Converts an array into CSV data
  • Operation Array : Perform mathematical operations on all the values of a property in an array
  • Operation Item : Perform mathematical operations to individual items within an array
  • Item Extractor : Extract specific items and values from arrays
  • Calibration 2D : Map data from a sensor to a display environment
  • Speed : Computes the speed of a property in an array by monitoring it over time
  • Friction : Adds acceleration/deceleration values to an item’s properties to smoothen moves
  • Angular Speed : Computes the angular speed of a property in an array by monitoring it over time
  • Blob Tracker : Detect and track blobs in CV Image
  • World Transform : Compute a 3D transformation matrix to convert one 3D sensor’s data into another one’s universe.
  • Trailing : Compute a trail on every item of a specified array

Arrays as strings

When passed from one node to the next, arrays are packed into a string in Kinetic Designer.

The string is a single line containing the entire array and built as such :

  • An item starts with the ID followed by a column : opening the item and a semi-colon ; closes the item
  • Each property and its value is then declared in the following manner Property@ Value
  • Items are separated by a comma ,
  • Indexes are not included in the string, and will be created locally when required by parsing the string to build the array.

Example

The following string:

0:X@960,Y@540,Lifetime@314;1:X@128,Y@128,Lifetime@159
will produce the following array:

Sample array in a Listing node

Need more help with this?
Don’t hesitate to contact us here.

Thanks for your feedback.