|
| 1 | +.. _coordinates: |
| 2 | + |
| 3 | +Coordinate Systems |
| 4 | +================== |
| 5 | +Scenic's coordinate system consists of a global coordinate system based on intrinsic Euler angles and a local coordinate system |
| 6 | +which can built and used via differnt properties and specifiers. We will describe the coordinate systems in the more detail below. |
| 7 | + |
| 8 | +Global Coordinate System |
| 9 | +------------------------ |
| 10 | +All objects in Scenic have an :prop:`orientation` property, which is their orientation in global coordinates. |
| 11 | +Scenic represents orientations internally using quaternions, though for convenience they can be created using Euler angles. Scenic follows the right hand rule with the Z,X,Y order of rotations. In other words, Euler angles are given as (Yaw, Pitch, Roll), in radians, and applied in that order. |
| 12 | + |
| 13 | +:prop:`orientation` is derived from the values of 4 other properties, :prop:`parentOrientation`, :prop:`yaw`, :prop:`pitch`, and :prop:`roll`. |
| 14 | +The :prop:`parentOrientation` property defines the parent orientation of the object, which is the orientation with respect to which the intrinsic Euler angles :prop:`yaw`, :prop:`pitch`, and :prop:`roll` are interpreted. |
| 15 | +Specifically, :prop:`orientation` is obtained as follows: |
| 16 | + |
| 17 | + 1. start from :prop:`parentOrientation`; |
| 18 | + 2. apply a yaw (a :abbr:`CCW (counter-clockwise)` rotation around the positive Z axis) of :prop:`yaw`; |
| 19 | + 3. apply a pitch (a CCW rotation around the resulting positive X axis) of :prop:`pitch`; |
| 20 | + 4. apply a roll (a CCW rotation around the resulting positive Y axis) of :prop:`roll`. |
| 21 | + |
| 22 | +Below is an illustration of the global coordinate system |
| 23 | + |
| 24 | +.. image:: /images/global_coords.jpg |
| 25 | + :width: 50% |
| 26 | + |
| 27 | +By default, :prop:`parentOrientation` is aligned with the global coordinate system, so that :prop:`yaw` for example is just the angle by which to rotate the object around the Z axis. |
| 28 | + |
| 29 | +This corresponds to the :prop:`heading` property in older versions of Scenic. :prop:`heading` represents yaw in the global XY plane. Scenic represents headings in radians, measured anticlockwise from North, so that a heading of 0 is due North and a heading of π/2 is due West. |
| 30 | + |
| 31 | +For more information on orientations and heading please consult: |
| 32 | + |
| 33 | + * Tutorial on Orientations :ref:`orientations_tutorial` |
| 34 | + * Reference on Orientations: :ref:`Orientation`. |
| 35 | + * Reference on Heading: :ref:`Heading` |
| 36 | + |
| 37 | +Local Coordinate System |
| 38 | +----------------------- |
| 39 | +If you want to specify an objects coordinate system relative to other objects, there are specifiers for the :prop:`orientation` to do so. |
| 40 | + |
| 41 | + 1. The :specifier:`on {region}` specifier specifies :prop:`parentOrientation` whenever the region in question has a :term:`preferred orientation`: a `vector field` (another primitive Scenic type) which defines an orientation at each point in the region. |
| 42 | + 2. The :specifier:`ahead of` specifier only specifies :prop:`parentOrientation` *optionally*, giving it a new default value: if you want a different value, you can override that default by explicitly writing :specifier:`with parentOrientation {value}`. |
| 43 | + 3. The general operator :scenic:`{X} relative to {Y}` can interpret vectors and orientations as being in a variety of local coordinate systems |
| 44 | + 4. The `OrientedPoint` class adds :prop:`position` and :prop:`orientation` (plus :prop:`parentOrientation`, :prop:`yaw`, etc.) to define a local coordinate sytem. |
| 45 | + |
| 46 | +For more information on defining a local coordinate system, please consult: |
| 47 | + |
| 48 | + * Tutorial on :scenic:`relative to`: :ref:`dependencies_and_modifying_specifiers` |
| 49 | + * Reference on :scenic:`relative to` for headings: :ref:`operators` |
| 50 | + * Reference on `OrientedPoint`: :ref:`OrientedPoint` |
| 51 | + |
0 commit comments