Coordinate Systems

Several coordinate systems are involved when working with shapes. All transformations described above operate in the system defined by the current shape's scope, the scope system. There is also a pivot system associated to each shape, and every shape defines an object coordinate system.

In the table below, all four coordinate systems involved in the CGA Shape Grammar are presented by means of the example whose rules are to be found further below.

World Coordinate System
Shapes are defined in world coordinates. The world coordinate system can be visualized by enabling → Grid in the viewport and Menu: Edit → Preferences → General → Viewport → Show axes.
Object Coordinate System
On generation, a local coordinate system is defined for each shape. The origin is placed at the first point of the initial shape's first edge, and the axes are oriented such that the x-axis is along the first edge, the y-axis is along the first face's normal and the z-axis is perpendicular to the former two.
The orientation and the position of the object system can be queried (see the initialShape attribute in the CGA shape grammar reference).
Pivot Coordinate System
Each shape has an associated pivot coordinate system. The pivot is described in object space, i.e., relative to the shape's origin. The pivot is adjusted on component splits (placed at the first point of the first edge of the component, with x along the first line and z along the face normal).
Therefore, the pivot coordinate system defines a standard coordinate system for e.g. facades.
The orientation and the position of the pivot system can be queried (see the pivot attribute in the CGA shape grammar reference) and visualized (see Working with the Shape Tree Explorer).
Scope Coordinate System
Each shape has an associated scope coordinate system. The scope is described in pivot space and has a size, i.e., is the bounding box of the scope's geometry. The typical shape transformations operate on the scope (see Transformations).
The rotation and the translation of the scope system can be queried (see the scope attribute in the CGA shape grammar reference) and visualized (see Working with the Shape Tree Explorer).

Note: The scope in the picture on the right is flat, i.e., its z-dimension is 0.

The picture below shows the rule applied on two identical (but differently positioned) lots.



The object space origin, pivot and scope of one corresponding shape are visualized in both generated models. The rule also prints the numerical representations of the highlighted elements. For lot A, the ouptut looks as follows:
initialShape.origin.p = 10.5274, 0, 32.9774
initialShape.origin.o = -0, -30.0738, 0
pivot.p = 7.5134, 0, 1.90735e-006
pivot.o = 0, 95.6808, 0
scope.t = 0, 15, 0
scope.r = 0, 0, 0
And the output for lot B:
initialShape.origin.p = -17.9412, 0, 8.9387
initialShape.origin.o = -0, -79.7078, 0
pivot.p = 7.5134, 0, 0
pivot.o = 0, 95.6808, 0
scope.t = 0, 15, 0
scope.r = 0, 0, 0
Note that only the initialShape.origin attribute differs; all the other values are the same for both models. Also note the tiny error in the pivot.pz value (0 vs. 1.90735e-006); this is a typical floating-point arithmetic's roundoff error.

Finally the cga code:
/**
 * File:    test_0115_coordinate_systems.cgaref.cga
 * Created: 28 Aug 2009 08:08:10 GMT
 * Author:  dec
 */

version "2009.2"

Lot-->
   extrude(20)
   comp(f) { 3 : FacadeSpec | side : Facade | top : Roof }

Facade-->
   split(y) { 5 : Floor }*
	
FacadeSpec-->
   split(y) { 5 : FloorSpec }*
	
FloorSpec-->
   case split.index == 3:
      print("initialShape.origin.p = " + initialShape.origin.px + ", " + 
             initialShape.origin.py + ", " + initialShape.origin.pz)
      print("initialShape.origin.o = " + initialShape.origin.ox + ", " + 
             initialShape.origin.oy + ", " + initialShape.origin.oz)
      print("pivot.p = " + pivot.px + ", " + pivot.py + ", " + pivot.pz)
      print("pivot.o = " + pivot.ox + ", " + pivot.oy + ", " + pivot.oz)
      print("scope.t = " + scope.tx + ", " + scope.ty + ", " + scope.tz)
      print("scope.r = " + scope.rx + ", " + scope.ry + ", " + scope.rz)
      X
   else:
      X

Copyright ©2008-2016 Esri R&D Center Zurich. All rights reserved.