Transformations#

Both of the following are given as top-level attributes of a JSON object, and change where the object is placed or how it is oriented.

Affine transformations#

Model objects (meshes, shapes, models, etc.) of an archetype that contains an AffineTransformations component can define arbitrary affine transformations (rotation, translation, scale) in any order, as top-level attributes. These transformations will be applied to the local transformation matrix of the model in the same order they are defined in the JSON file.

The supported attributes, and their names, are:

  • translate – contains a 3-vector with a translation in internal units.

    Example: "translate" : [2.0, 0.0, 5.0].

  • translatePc – contains a 3-vector with a translation in parsecs.

    Example: "translatePc" : [2.0, 0.0, 5.0].

  • translateKm – contains a 3-vector with a translation in kilometers.

    Example: "translateKm" : [25000.0, 0.0, 0.0].

  • scale – contains either a single floating-point value or a 3-vector with the scaling factor, in local model coordinates.

    Example: "scale" : [1.0, 1.0, 2.0], scales the model \(\times 2\) in the Z component.

  • rotate – contains a 4-vector where the first three components are the rotation axis, and the last component is the rotation angle in degrees.

    Example: "rotate": [1.0, 0.0, 0.0, 45.0], rotates the model \(45^\circ\) around the \(\begin{pmatrix} 1 & 0 & 0 \end{pmatrix}\) vector.

For instance, the following JSON object,

{
  "name": "Object name",
  "color": [ 0.4, 0.4, 1.0, 0.4 ],
  "labelColor": [ 0.4, 0.4, 1.0, 1.0 ],
  "labelFactor": 0.0004,
  "sizePc": 1.0,
  "componentType": "Others",
  "parent": "Parent name",
  "archetype": "ShapeObject",
  "renderGroup": "MODEL_VERT_ADDITIVE",

  "rotate": [ 0.0, 1.0, 0.0, 60.0 ],
  "scale": [ 2.0, 0.5, 0.5 ],

  "coordinates": {
    "impl": "gaiasky.util.coord.StaticCoordinates",
    "position": [ 0.0, 0.0, 0.0 ]
  },
  "model": {
    "args": [ true ],
    "staticLight": true,
    "type": "sphere",
    "primitiveType": "lines",
    "blendMode": "additive",
    "params": { "quality": 30, "diameter": 1.0, "flip": true }
  }
}

defines a sphere which is scaled \(\times 2\) in X and \(\times 0.5\) in Y and Z, and rotated around the Y axis \(60^\circ\).

Reference system transformations#

Gaia Sky uses an equatorial internal reference system. Objects of an archetype that contains a RefSysTransform component can specify reference system transformations directly in the JSON file as top-level attributes using the "transformName" or "transformFunction" names. These attributes take in a string with the name of the transformation. The possible values are:

  • “transformFunction”: “equatorialToEcliptic”

  • “transformFunction”: “equatorialToGalactic”

  • “transformFunction”: “eclipticToEquatorial”

  • “transformFunction”: “eclipticToGalactic”

  • “transformFunction”: “galacticToEquatorial”

  • “transformFunction”: “galacticToEcliptic”

These are turned into a 4x4 matrix with the necessary reference system rotation.

Additionally, it is possible to specify the 16 values of the matrix themselves, in column-major order, using the top-level attributes "transformMatrix" or the alias "transformValues".

Example:

{
  "name": "Object name",
  "color": [ 0.4, 0.4, 1.0, 0.4 ],
  "labelColor": [ 0.4, 0.4, 1.0, 1.0 ],
  "labelFactor": 0.0004,
  "sizePc": 1.0,
  "componentType": "Others",
  "parent": "Parent name",
  "archetype": "ShapeObject",
  "renderGroup": "MODEL_VERT_ADDITIVE",

  "transformMatrix": [0.7660444431189781, 0.0, -0.12855752193730788, 0.0,
                      0.0,                0.5,  0.0,                 0.0,
                      0.6427876096865394, 0.0,  0.15320888862379564, 0.0,
                      0.0,                0.0,  0.0,                 1.0],
  "coordinates": {
    "impl": "gaiasky.util.coord.StaticCoordinates",
    "position": [ 0.0, 0.0, 0.0 ]
  },
  "model": {
    "args": [ true ],
    "staticLight": true,
    "type": "sphere",
    "primitiveType": "lines",
    "blendMode": "additive",
    "params": { "quality": 30, "diameter": 1.0, "flip": true }
  }
}