Transformations for 3D View Elements

Transformations are defined in the org.opensourcephysics.numerics.Transformation interface as objects which transform a point in 3D space to another point. Most transformations are invertible (such as rigid motions, for instance), but they don't need to be.

The class org.opensourcephysics.numerics.Matrix3DTransformation provides utilities to create the most frequently used transformations, as well as to multiply them to obtain more sophisticated ones. Some of the factory (static) methods of this class are:

Objects of the Matrix3DTransformation class support the following methods:

To use any of these methods, we recommend that you first import the org.opensourcephysics.numerics.Matrix3DTransformation class (through the Import Statements of the Custom panel of Ejs) . Then, you can write code such as:

  Matrix3DTransformation firstTransf  = Matrix3DTransformation.rotationX(Math.PI/4.0);
  Matrix3DTransformation secondTransf = Matrix3DTransformation.rotationY(Math.PI/2.0);
  firstTransf.multiply(secondTransf); // i.e. firstTransf followed by secondTransf
  _view.myElement3D.setTransformation(firstTransf);
where myElement3D is a 3D element.

A simple static transformation (i.e. one that will not change during the execution of the simulation) can be specified in the Transform property of a 3D view element using one of the following arrays of double constants: