Main /
ElementsRotation3DThe 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:
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:
Dynamic values Here an example of declaring (but not yet initializing) an axis with values that may change over the course of a simulation:
And then on a subsequent panel:
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:
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
Finally, the rotation can be enabled an disabled temporarily using the 'Enabled' property. |