Coordinate System

Overview

The CoordinateSystem object is used to define Cartesian, cylindrical, spherical and toroidal coordinate systems. The systems are defined given an origin and orientation relative to the global coordinate system. The methods associated with a CoordinateSystem object are the following.

Once a CoordinateSystem object is instanced, define the coordinate system type using define(). Coordinate system types include Cartesian, cylindrical, toroidal and two variations of spherical systems. After the coordinate system type is defined then set the coordinate system origin and orientation direction cosine matrix using setOriginAndDirectionCosines(). If the user is only concerned with the orientation of the z axis then use setOriginAndZAxis(). In this case the directions of the x and y axes will be automatically generated.

The following convention for the direction cosine matrices of a local coordinate system is used. Given that x’,y’ and z’ are three orthonormal vectors indicating the direction of the local coordinate axes in the global coordinate system (x,y,z), then the direction cosine matrix, tm for this local coordinate system is defined as:

tm[0][0] = x'x  tm[0][1] = x'y  tm[0][2] = x'z
tm[1][0] = y'x  tm[1][1] = y'y  tm[1][2] = y'z
tm[2][0] = z'x  tm[2][1] = z'y  tm[2][2] = z'z

where y’x, for example, is the global x coordinate of the y’ unit vector.

Note that all CoordinateSystem functions involving floating point data have both single and double precision versions. The single precision versions are provided for convenience, all floating point data is held internally in the CoordinateSystem object in double precision.

The orientation of the coordinate system is specified by a direction cosine matrix which defines a local x’,y’,z’ rectangular system in global coordinate space. The coordinate system is aligned to the x’,y’,z’ system. Note that all angles are in degrees.

  • A Cartesian system is a rectangular coordinate system characterized by coordinates x’,y’,z’.
  • A cylindrical system is characterized by coordinates r,theta,z’ where theta is the angle about the z’ axis (positive x’ toward positive y’). An alternate definition of a cylindrical system is available characterized by coordinates z,theta,r where theta is the angle about the z’ axis (positive y’ toward positive x’).
  • A spherical system is characterized by coordinates r,theta,phi where theta is the angle about the z’ axis (positive x’ toward positive y’) and phi is the angle about the x’ axis (positive y’ toward positive z’). An alternate definition of a spherical system is available (for specific support of NASTRAN spherical coordinate systems) in which theta is the angle about the negative x’ axis (positive z’ toward positive y’) and phi is the angle about the z’ axis (positive x’ toward positive y’).
  • A toroidal system is characterized by a radius of the torus and coordinates r,theta,phi where theta is the angle about the z’ axis (positive x’ toward positive y’) and phi is the angle about the x’ axis (positive y’ toward positive z’).

Figure 2-1 illustrates the coordinate system conventions. Use the Triad object to draw coordinate systems.

../../../_images/vistools-vc1.gif

Figure 2-1, Coordinate System Conventions

The functions transformVectorToLocalSystem(), transformTensorToLocalSystem() and transformMatrixToLocalSystem() may be used to convert a vector, tensor or general tensor at a point P expressed in the global Cartesian system to a local Cartesian system which is dependent upon the coordinate location of P. The functions transformVectorToGlobalSystem(), transformTensorToGlobalSystem() and transformMatrixToGlobalSystem() perform the inverse transformation. See section VisTools, Mathematical Data Types for a description of ordering conventions for the components of vectors, tensors and general tensors. The local Cartesian system at point P may be computed using computeDirectionCosines().

The function computeDirectionCosines() may be used to compute the direction cosine matrix of a local Cartesian coordinate system at a point. Figure 2-2 illustrates the local Cartesian direction cosine matrix x’,y’,z’ computed at a point P within a cylindrical coordinate system. The x’ local axis is in the radial direction at P, the y’ local axis is in the tangential direction at P and the z’ axis is in the axial direction. The equivalent, rotation angle vector representation of the local Cartesion system at point P may be computed using computeRotationAngles(). This rotation angle vector may be converted to a direction cosine matrix using the Rodrigues formula. It is a vector whose direction is the axis of rotation and whose magnitude is the rotation angle in degrees.

../../../_images/vistools-vc2.gif

Figure 2-2, Local Cartesian Direction Cosine Matrix

The function transformToLocalSystem() may be used to convert a coordinate location expressed in global Cartesian coordinates to the coordinate system type. This operation involves subtracting the offset of the coordinate system origin and converting to the coordinate sytem type. For cylindrical, alternate cylindrical, spherical, alternate spherical and toroidal systems the coordinates are converted to (r,theta,z’), (z’,theta,r), (r,theta,phi) (r,theta,phi) and (r,theta,phi) respectively. The function transformToGlobalSystem() performs the inverse operation.

Class Members Descriptions

The currently available CoordinateSystem enumerations and functions are described in detail in this section.

class CoordinateSystem

Coordinate System management.

Public Functions

ErrorCode getErrorCode()

Return the current ErrorCode of the CoordinateSystem object.

Returns: ErrorCode - The current error code, or NONE if no error.
Status define(CoordinateSystemType type)

Define the coordinate system type. Set the origin and orientation of the system using setOriginAndDirectionCosines() , setOriginAndRotationAngles() , setOriginAndVectors() or setOriginAndZAxis() . Set the radius of a toroidal system using setTorusRadius() .

See Also inquire()

Parameters:type – Coordinate system type
Returns:Status
Status inquire(CoordinateSystemType *type)

Inquire of defined type as an output argument.

See Also define()

Parameters:type[out] Coordinate system type
Returns:Status
Status setOriginAndZAxis(double originCoord[3], double zAxisVector[3])

Specify the coordinate system origin in global coordinates and the system z axis direction vector. The direction vector should be a unit vector. The orientations of the x and y axes are computed internally. This function is useful if only the z axis orientation of the system is critical. No check is performed by the CoordinateSystem object on the validity of the input vector.

Parameters:
  • originCoord – Origin of coordinate system in global coordinates
  • zAxisVector – Vector of system local z axis
Returns:

Status

Status setOriginAndVectors(double originCoord[3], double xVector[3], double xyVector[3])

Specify the coordinate system origin in global coordinates and the system as two vectors. The two vectors must form a valid x’-y’ plane.

Errors
COMPUTE is generated if the input vectors do not form a valid plane.

Parameters:
  • originCoord – Origin of coordinate system in global coordinates
  • xVector – Vector along x’ axis
  • xyVector – Vector in x’-y’ plane
Returns:

Status

Status setOriginAndRotationAngles(double originCoord[3], double rotationAngles[3])

Specify the coordinate system origin in global coordinates and the system orientation using the rotation angle vector.

Errors
COMPUTE is generated if the input vectors do not form a valid plane.

Parameters:
  • originCoord – Origin of coordinate system in global coordinates
  • rotationAngles – Rotation angle vector of system local axes
Returns:

Status

Status setOriginAndDirectionCosines(double originCoord[3], double directionCosines[3][3])

Specify the coordinate system origin in global coordinates and the system orientation. The direction cosine matrix should be a proper orthonormal rotation matrix. No check is performed by the CoordinateSystem object on the validity of the input matrix.

Parameters:
  • originCoord – Origin of coordinate system in global coordinates
  • directionCosines – Direction cosine matrix of system local axis
Returns:

Status

Status setTorusRadius(double radius)

Specify the radius of the torus for a toroidal coordinate system. By default the radius is unity.

See Also getTorusRadius()

Parameters:radius – Radius of torus
Returns:Status
Status getTorusRadius(double *radius)

Get the radius of the torus for a toroidal coordinate system.

See Also setTorusRadius()

Parameters:radius[out] Radius of torus
Returns:Status
Status computeDirectionCosines(double originCoord[3], double directionCosines[3][3])

Compute the direction cosine matrix associated with a specified global coordinate location. For Cartesian systems, the matrix is independent of location and is aligned exactly with the system x’,y’,z’ axes. For cylindrical systems, the x local axis is in the radial direction at the location, the y local axis is in the tangential direction and the z local axis is in the axial direction. For spherical systems, the x local axis is in the radial direction at the location, the y local axis is in the tangential direction and the z local axis is constructed to be orthonormal to the x local and y local axes. If the location is at the coordinate system origin, then the direction cosine matrix is always aligned to the system x’,y’,z’ axes. For toroidal systems, the x local axis is in the radial direction at the location, the y local axis is in the tangential direction and the z local axis is constructed to be orthonormal to the x local and y local axes.

See Also computeRotationAngles()

Parameters:
  • originCoord – Global coordinate location
  • directionCosines[out] Direction cosine matrix of system local axis
Returns:

Status

Status computeRotationAngles(double originCoord[3], double rotationAngles[3])

Compute the rotation angle vector associated with a specified global coordinate location. This is a compact rotation angle vector using the Rodriques formula which is equivalent to the direction cosine matrix computed using computeDirectionCosines() .

See Also computeDirectionCosines()

Parameters:
  • originCoord – Global coordinate location
  • rotationAngles[out] Rotation angle vector of system local axes
Returns:

Status

Status getDirectionCosines(double originCoord[3], double directionCosines[3][3])

Query the coordinate system origin in global coordinates and the system orientation.

See Also getRotationAngles()

Parameters:
  • originCoord[out] Origin of coordinate system in global coordinates
  • directionCosines[out] Direction cosine matrix of system local axis
Returns:

Status

Status getRotationAngles(double originCoord[3], double rotationAngles[3])

Query the coordinate system origin in global coordinates and the system orientation as a rotation angle vector.

See Also getDirectionCosines()

Parameters:
  • originCoordx[out] Origin of coordinate system in global coordinates
  • rotationAngles[out] Rotation angle vector of system local axis
Returns:

Status

Status transformToLocalSystem(double globalCoord[3], double localCoord[3])

Convert global coordinate location to local coordinates.

See Also transformToGlobalSystem()

Parameters:
  • globalCoord – Global coordinates
  • localCoord[out] Local coordinates
Returns:

Status

Status transformToGlobalSystem(double localCoord[3], double globalCoord[3])

Compute global coordinate location of a point expressed in local coordinates.

See Also transformToLocalSystem()

Parameters:
  • localCoord – Local coordinates
  • globalCoord[out] Global coordinates
Returns:

Status

Status transformVectorToGlobalSystem(double globalCoord[3], double localVector[3], double globalVector[3])

Compute a vector expressed in global coordinates given the vector expressed in local coordinates at global coordinate location.

See Also transformVectorToLocalSystem()

Parameters:
  • globalCoord – Global coordinate location
  • localVector – Vector in local coordinates
  • globalVector[out] Vector in global coordinates
Returns:

Status

Status transformTensorToGlobalSystem(double globalCoord[3], double localTensor[6], double globalTensor[6])

Compute a symmetric tensor expressed in global coordinates given the tensor expressed in local coordinates at global coordinate location.

See Also transformTensorToLocalSystem()

Parameters:
  • globalCoord – Global coordinate location
  • localTensor – Tensor in local coordinates
  • globalTensor[out] Tensor in global coordinates
Returns:

Status

Status transformMatrixToGlobalSystem(double globalCoord[3], double localMatrix[9], double globalMatrix[9])

Compute a general tensor expressed in global coordinates given the general tensor expressed in local coordinates at global coordinate location.

See Also transformMatrixToLocalSystem()

Parameters:
  • globalCoord – Global coordinate location
  • localMatrix – General tensor in local coordinates
  • globalMatrix[out] General tensor in global coordinates
Returns:

Status

Status transformVectorToLocalSystem(double globalCoord[3], double globalVector[3], double localVector[3])

Convert a vector expressed in global coordinates at global coordinate location to the vector expressed in local coordinates.

See Also transformVectorToGlobalSystem()

Parameters:
  • globalCoord – Global coordinate location
  • globalVector – Vector in global coordinates
  • localVector[out] Vector in local coordinates
Returns:

Status

Status transformTensorToLocalSystem(double globalCoord[3], double globalTensor[6], double localTensor[6])

Convert a symmetric tensor expressed in global coordinates at global coordinate location to the tensor expressed in local coordinates.

See Also transformTensorToGlobalSystem()

Parameters:
  • globalCoord – Global coordinate location
  • globalTensor – Tensor in global coordinates
  • localTensor[out] Tensor in local coordinates
Returns:

Status

Status transformMatrixToLocalSystem(double globalCoord[3], double globalMatrix[9], double localMatrix[9])

Convert a general tensor expressed in global coordinates at global coordinate location to the general tensor expressed in local coordinates.

See Also transformMatrixToGlobalSystem()

Parameters:
  • globalCoord – Global coordinate location
  • globalMatrix – General tensor in global coordinates
  • localMatrix[out] General tensor in local coordinates
Returns:

Status

Status setId(int id)

Set the coordinate system identifier.

See Also getId()

Parameters:id – Coordinate system identifier
Returns:Status
Status getId(int *id)

Get the coordinate system identifier.

See Also setId()

Parameters:id[out] Coordinate system identifier
Returns:Status
Status setName(const char *name)

Set the coordinate system name.

See Also getName()

Parameters:name – Coordinate system name
Returns:Status
Status getName(char name[])

Get the coordinate system name.

See Also setName()

Parameters:name[out] Coordinate system name
Returns:Status
Status print()

Print the coordinate system object information to standard output.

Returns:Status
Status copy(CoordinateSystem *from)

Make a copy of a CoordinateSystem object. The private data from the from object is copied to this object. Any previous private data in this object is lost.

Parameters:fromCoordinateSystem object to copy from
Returns:Status
Status transform(double translation[3], double rotation[3][3])

Transform CoordinateSystem by a translation and a rotation.

Parameters:
  • translation – Translation vector
  • rotation – Rotation direction cosine matrix
Returns:

Status