5.10. Transformation
Prev | Up | Chapter 5. Operators | Home | Next

## 5.10. Transformation #

As in a plane, translations and rotations are needed to do object or coordinate transformations. With pgSphere, it is done using Euler transformations (`strans`). On a sphere, there aren't real translations. All movements on a sphere are rotations around axes.

The general syntax for a transformation is always:

    object operator euler

where operators are `+` for a usual transformation, `-` for an inverse transformation. You can transform any object having a pgSphere data type, except the data type `sbox`.

Example 5.16. Transformation of a point

Rotate a spherical point counterclockwise, first 90° around the `x`-axis, second 90° around the `z`-axis, and last 40.5° around the `x`-axis.

    sql> SELECT set_sphere_output('DEG');
     set_sphere_output
    -------------------
     SET DEG
    (1 row)

    sql> SELECT spoint '(30d,0d)' + strans '90d, 90d, 40.5d, XZX AS spoint';
       spoint
    ---------------
     (90d , 70.5d)
    (1 row)

You can use the `+` and `-` operator as unary operators for transformations, too. `+`strans`` just returns the transformation itself, `-`strans`` returns the inverse transformation.

Example 5.17. An inverse transformation

    sql> SELECT set_sphere_output('DEG');
     set_sphere_output
    -------------------
     SET DEG
    (1 row)

    sql> SELECT - strans '20d, 50d, 80d, XYZ' AS inverted;
          inverted
    -----------------------
     280d, 310d, 340d, ZYX
    (1 row)

Prev | Up | Next
5.9. Turn the path of a line | Home | 5.11. `smoc` operators