convert function

Syntax

  • float convert(coordSelector, fromSysSelector, toSysSelector, typeSelector, x, y, z)

Parameters

  1. coordSelectorfloat
    { x | y | z }—coordinate component selector.
  2. fromSysSelectorfloat
    { scope | pivot | object | world }—selector for coordinate system to which to convert.
  3. toSysSelectorfloat
    { scope | pivot | object | world }—selector for coordinate system to which to convert.
  4. typeSelectorfloat
    { pos | orient }—selector to choose interpretation of the x, y, z - triple as coordinates or angles.
  5. x, y, zfloat
    Position (coordinates) / orientation (angles in degrees) in the fromSystem to convert to the toSystem.

Returns

The selected coordinate component of the tuple (x, y, z), converted from the fromSys coordinate system to the toSys coordinate system. The tuple can either describe angles or a position.

Description

The convert function converts positions and orientations between different coordinate systems.

Related

Examples

Using convert() to find the position and orientation of the scope origin in world and pivot coordinates as well as the highest point of the scope in world coordinates

Init-->
   extrude(3)
   t('0.2, 0, '0.7)
   s('0.5, '1, '0.5)
   r(-10, 70, 0)
	 
   print("pos. of scopeOrigin in world coords " +
      convert(x, scope, world, pos, 0, 0, 0) + ", " +
      convert(y, scope, world, pos, 0, 0, 0) + ", " +
      convert(z, scope, world, pos, 0, 0, 0) )
   print("orient. of scopeOrigin rel. to world axes " +
      convert(x, scope, world, orient, 0, 0, 0) + ", " +
      convert(y, scope, world, orient, 0, 0, 0) + ", " +
      convert(z, scope, world, orient, 0, 0, 0) )
   print("pos. of scopeOrigin in pivot coords " +
      convert(x, scope, pivot, pos, 0, 0, 0) + ", " +
      convert(y, scope, pivot, pos, 0, 0, 0) + ", " +
      convert(z, scope, pivot, pos, 0, 0, 0) )
   print("highest point in world coords " +
      convert(x, scope, world, pos, scope.sx, scope.sy, scope.sz)
      + ", " +
      convert(y, scope, world, pos, scope.sx, scope.sy, scope.sz)
      + ", " +
      convert(z, scope, world, pos, scope.sx, scope.sy, scope.sz) )
Convert function

The output of the cga code:

CGA code output

In this topic