ElementsRotation3D

The rotation3D element can be appended as a child element of a 3D drawable to apply a single rotation to it. If you append two or more rotations as child elements, then EJS will perform those rotations in sequence.

The element properties of rotation3D.

The 'Angle' property can be set to an integer or to a double (floating point) value. If integer, it is taken as an angle in degrees. If double, then it is considered to be given in radians.

If you hover over the word 'Axis' you get the tooltip, stating the kind of input that the element property accepts, which is double[]. The angled brackets indicate an array. Since the array specifies a 3D vector, the dimension must be 3.

If this Axis property is to be set to an array of values that will vary over the course of a simulation then first declaring the array on the Variables panel is a necessity. However, if the array of values will be constant anyway declaring on the Variables panel is optional; using the following syntax it can be declared in the property field directly:

new double[] {0,1,1}

which in this case will make it a rotation around the bisectrix of the YZ plane. (The notation {0,1,1} is one of the ways Java supports to specify the values of the respective positions in the array.)

Here is an example how the unit vectors for x, y and z direction can be declared and initialized on the Variables Panel:

Here an example of declaring (but not yet initializing) an axis with values that may change over the course of a simulation:

name initial value type dimension axis double [3]

And then on a subsequent panel:

axis[0] = expression0; axis[1] = expression1; axis[2] = expression2;

Usually these expressions will contain sines and cosines and the like. Note that the first position of the array has index 0.

A more compact form is also available:
axis = new double[] {expression0, expression1, expression2};
This re-declares and initializes the array in one single line.

The rotation axis passes by default through the element's origin. But it can be displaced and made it to pass to a given position, relative to the element's origin, as specified by the 'Position Array' property. For instance, setting it to
new double[] {-0.5,0,0};
will rotate an element of Size X = 1 around one of its sides, instead of around its center.

Finally, the rotation can be enabled an disabled temporarily using the 'Enabled' property.