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.
- Define and query coordinate system type
define()- Define coordinate system typeinquire()- Inquire coordinate system type
- Operations
transformToGlobalSystem()- Compute coordinates in global systemtransformVectorToGlobalSystem()- Compute vector in global systemtransformTensorToGlobalSystem()- Compute tensor in global systemtransformMatrixToGlobalSystem()- Compute general tensor in global systemtransformToLocalSystem()- Convert coordinates to local systemtransformVectorToLocalSystem()- Convert vector to local systemtransformTensorToLocalSystem()- Convert tensor to local systemtransformMatrixToLocalSystem()- Convert general tensor to local systemcomputeDirectionCosines()- Compute direction cosine matrixcomputeRotationAngles()- Compute rotation angle vectorgetDirectionCosines()- Query origin and orientationgetRotationAngles()- Query origin and orientationsetOriginAndRotationAngles()- Specify origin and angle orientationsetOriginAndDirectionCosines()- Specify origin and triad orientationsetOriginAndVectors()- Specify origin and vector orientationsetOriginAndZAxis()- Specify origin and z axis orientationsetTorusRadius()- Specify radius of torusgetTorusRadius()- Query radius of torustransform()- Translate and rotate a coordinate system
- General functions
print()- Print object contentscopy()- Make a copy of a CoordinateSystem objectgetErrorCode()- Get error codesetId()- Set identifiergetId()- Get identifiersetName()- Set namegetName()- Get name
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.
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.
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
-
HOOPS_CAE_EXTERN ErrorCode getErrorCode () Return the current
ErrorCodeof the CoordinateSystem object.Returns: ErrorCode- The current error code, orNONEif no error.
-
HOOPS_CAE_EXTERN Status define (CoordinateSystemType type) Define the coordinate system type. Set the origin and orientation of the system using
setOriginAndDirectionCosines,setOriginAndRotationAngles,setOriginAndVectorsorsetOriginAndZAxis. Set the radius of a toroidal system usingsetTorusRadius.See Also
inquireParameters: type – Coordinate system type Returns: Status
-
HOOPS_CAE_EXTERN Status inquire (CoordinateSystemType *type) Inquire of defined type as an output argument.
See Also
defineParameters: type – [out] Coordinate system type Returns: Status
-
HOOPS_CAE_EXTERN 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:
-
HOOPS_CAE_EXTERN 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
-
COMPUTEis 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:
-
HOOPS_CAE_EXTERN 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
-
COMPUTEis 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:
-
HOOPS_CAE_EXTERN 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:
-
HOOPS_CAE_EXTERN Status setTorusRadius (double radius) Specify the radius of the torus for a toroidal coordinate system. By default the radius is unity.
See Also
getTorusRadiusParameters: radius – Radius of torus Returns: Status
-
HOOPS_CAE_EXTERN Status getTorusRadius (double *radius) Get the radius of the torus for a toroidal coordinate system.
See Also
setTorusRadiusParameters: radius – [out] Radius of torus Returns: Status
-
HOOPS_CAE_EXTERN 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
computeRotationAnglesParameters: - originCoord – Global coordinate location
- directionCosines – [out] Direction cosine matrix of system local axis
Returns:
-
HOOPS_CAE_EXTERN 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
computeDirectionCosinesParameters: - originCoord – Global coordinate location
- rotationAngles – [out] Rotation angle vector of system local axes
Returns:
-
HOOPS_CAE_EXTERN Status getDirectionCosines (double originCoord[3], double directionCosines[3][3]) Query the coordinate system origin in global coordinates and the system orientation.
See Also
getRotationAnglesParameters: - originCoord – [out] Origin of coordinate system in global coordinates
- directionCosines – [out] Direction cosine matrix of system local axis
Returns:
-
HOOPS_CAE_EXTERN 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
getDirectionCosinesParameters: - originCoordx – [out] Origin of coordinate system in global coordinates
- rotationAngles – [out] Rotation angle vector of system local axis
Returns:
-
HOOPS_CAE_EXTERN Status transformToLocalSystem (double globalCoord[3], double localCoord[3]) Convert global coordinate location to local coordinates.
See Also
transformToGlobalSystemParameters: - globalCoord – Global coordinates
- localCoord – [out] Local coordinates
Returns:
-
HOOPS_CAE_EXTERN Status transformToGlobalSystem (double localCoord[3], double globalCoord[3]) Compute global coordinate location of a point expressed in local coordinates.
See Also
transformToLocalSystemParameters: - localCoord – Local coordinates
- globalCoord – [out] Global coordinates
Returns:
-
HOOPS_CAE_EXTERN 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
transformVectorToLocalSystemParameters: - globalCoord – Global coordinate location
- localVector – Vector in local coordinates
- globalVector – [out] Vector in global coordinates
Returns:
-
HOOPS_CAE_EXTERN 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
transformTensorToLocalSystemParameters: - globalCoord – Global coordinate location
- localTensor – Tensor in local coordinates
- globalTensor – [out] Tensor in global coordinates
Returns:
-
HOOPS_CAE_EXTERN 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
transformMatrixToLocalSystemParameters: - globalCoord – Global coordinate location
- localMatrix – General tensor in local coordinates
- globalMatrix – [out] General tensor in global coordinates
Returns:
-
HOOPS_CAE_EXTERN 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
transformVectorToGlobalSystemParameters: - globalCoord – Global coordinate location
- globalVector – Vector in global coordinates
- localVector – [out] Vector in local coordinates
Returns:
-
HOOPS_CAE_EXTERN 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
transformTensorToGlobalSystemParameters: - globalCoord – Global coordinate location
- globalTensor – Tensor in global coordinates
- localTensor – [out] Tensor in local coordinates
Returns:
-
HOOPS_CAE_EXTERN 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
transformMatrixToGlobalSystemParameters: - globalCoord – Global coordinate location
- globalMatrix – General tensor in global coordinates
- localMatrix – [out] General tensor in local coordinates
Returns:
-
HOOPS_CAE_EXTERN Status setId (int id) Set the coordinate system identifier.
See Also
getIdParameters: id – Coordinate system identifier Returns: Status
-
HOOPS_CAE_EXTERN Status getId (int *id) Get the coordinate system identifier.
See Also
setIdParameters: id – [out] Coordinate system identifier Returns: Status
-
HOOPS_CAE_EXTERN Status setName (const char *name) Set the coordinate system name.
See Also
getNameParameters: name – Coordinate system name Returns: Status
-
HOOPS_CAE_EXTERN Status getName (char name[]) Get the coordinate system name.
See Also
setNameParameters: name – [out] Coordinate system name Returns: Status
-
HOOPS_CAE_EXTERN Status print () Print the coordinate system object information to standard output.
Returns: Status
-
HOOPS_CAE_EXTERN 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: from – CoordinateSystem object to copy from Returns: Status
-
HOOPS_CAE_EXTERN 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:
-