Recent Changes - Search:

Information

Installation

Documentation

ElementsSets2D

A set of elements is a collection of EJS elements of the same type. Technically they are stored in an array, which means that each element has an index number between 0 and n-1. The total number n of elements in a set would be the dimension of that array. Most of the properties of the individual elements of a set - such as their positions or colours - can be specified by providing either a single value (which is then applied to all elements of the set) or an array of the same or larger dimension. In this latter case, each entry of the array is applied to the corresponding element of the set. Unless the dimension is very small (say, 2 or 3, where you could type something like new double[] {0,1,0}), you cannot fill in multiple values into a single input field of the set's property dialogue, and you need to declare and fill in the value of arrays of the right dimension in the model variables.


Defining 3-dimensional arrays color, x, and y for e.g. a set of three 2D-shapes.

Once the property arrays are defined they can be manipulated e.g. in for-loops during initialization and evolution:

  for(int i = 0; i < y.length; i++) {         // Loop i from 0 to n-1             
    y[i] = y[i] + dy[i];                      // manipulate element with index i 
  }

The array variables can be used to define the view properties of a set of elements:


Use array variables for properties of e.g. SegmentSet2D.

Available sets for 2D elements

Edit - History - Print - Recent Changes - Search
Page last modified on November 08, 2010, at 02:01 AM