Core: Coordinate Systems and Transformations
This section describes the various coordinate systems used by Creo Parametric and Creo TOOLKIT, and how to transform coordinates from one to another.
Coordinate Systems
Creo Parametric and Creo TOOLKIT use the following coordinate systems:
•  Solid coordinate system
•  Screen coordinate system
•  Window coordinate system
•  Drawing coordinate system
•  Drawing view coordinate system
•  Assembly coordinate system
•  Datum coordinate system
•  Section coordinate system
The following sections describe each of these coordinate systems.
Solid Coordinate System
The solid coordinate system is the three-dimensional, Cartesian coordinate system used to describe the geometry of a Creo Parametric solid model. In a part, the solid coordinate system describes the geometry of the surfaces and edges. In an assembly, the solid coordinate system also describes the locations and orientations of the assembly members.
You can visualize the solid coordinate system in Creo Parametric by creating a coordinate system datum with the option Model  Coordinate System. Distances measured in solid coordinates correspond to the values of dimensions as seen by the Creo Parametric user.
Solid coordinates are used by Creo TOOLKIT for all the functions that look at geometry, and most of the functions that draw three-dimensional graphics.
Screen Coordinate System
The screen coordinate system is a two-dimensional coordinate system that describes locations in a Creo Parametric window. This is an intermediate coordinate system after which the screen points are transformed to screen pixels. All the models are first mapped to the screen coordinate system. When the user zooms or pans the view, the screen coordinate system follows the display of the solid, so a particular point on the solid always maps to the same screen coordinate. The mapping changes only when the view orientation is changed.
Screen coordinates are used by some of the graphics functions, the mouse input functions, and all the functions that draw graphics or manipulate items on a drawing.
Window Coordinate System
The window coordinate system is similar to the screen coordinate system. After mapping the models to the screen coordinate system, they are mapped to the window coordinate before being drawn to screen pixels based on screen resolution. When pan or zoom values are applied to the coordinates in the screen coordinate system, they result in window coordinates. When an object is first displayed in a window, or the option View  Refit is used, the screen and window coordinates are the same.
You can use the function ProWindowCoordinatePixelGet() to get the window point in pixel coordinates.
The 3D point that is projected to 2D will be visible on the screen only if it lies within the outline that is returned by the function ProWindowPixelOutlineGet(). If not, it will be clipped and will not be visible on the screen.
Drawing Coordinate System
The drawing coordinate system is a two-dimensional system that describes the location on a drawing relative to the bottom, left corner, and measured in drawing units. For example, on a U.S. letter-sized, landscape-format drawing sheet that uses inches, the top, right corner is (11, 8.5) in drawing coordinates.
The Creo TOOLKIT functions that manipulate drawings generally use screen coordinates.
Drawing View Coordinate System
This drawing view coordinate system is used to describe the locations of entities in a drawing view.
Assembly Coordinate System
An assembly has its own coordinate system that describes the positions and orientations of the member parts and subassemblies, and the geometry of datum features created in the assembly.
When an assembly is retrieved into memory, each member is loaded too, and continues to use its own solid coordinate system to describe its geometry.
This is important when you are analyzing the geometry of a subassembly, and want to extract or display the results relative to the coordinate system of the parent assembly.
Datum Coordinate System
A coordinate system datum can be created anywhere in any part or assembly, and represents a user-defined coordinate system. It is often a requirement in a Creo TOOLKIT application to describe geometry relative to such a datum.
Section Coordinate System
Every sketch has a coordinate system used to locate entities in that sketch. Sketches used in features will use a coordinate system different from that of the solid model.
Coordinate System Transformations
Functions Introduced:
All coordinate systems are treated in Creo TOOLKIT as if they were three-dimensional. Therefore, a point in any of the coordinate systems described is always represented in C by the following type:
     typedef double ProPoint3d[3]
Vectors are distinguished for clarity by a different, though equivalent, declaration:
     typedef double ProVector[3]
, Screen, window and section coordinates contain a Z value whose positive direction is normal to the screen or the sketch. The value of Z is not generally important when specifying a screen location as an input to a function, but it is useful in other situations. For example, if the user selects a datum plane, you can find out which side is towards the user by calculating the normal to the plane, transforming to screen coordinates, then looking at the sign of the Z coordinate.
A transformation between two coordinate systems is represented by a 4x4 matrix, with the following type:
typedef double ProMatrix[4][4];
This combines the conventional 3x3 matrix that describes the relative orientation of the two systems, and the vector that describes the shift between them.
Transformation Matrix
Image
Creo TOOLKIT provides two utilities for performing coordinate transformations. The function ProPntTrfEval() transforms a three-dimensional point, and ProVectorTrfEval() transforms a three-dimensional vector.
The source code for other utilities that manipulate transformation matrices is located in the file Matrix.c located at <creo_toolkit_loadpoint>/protk_appls/pt_examples/pt_utils/Util.
The following sections describe the functions needed to obtain the transformation matrix between two different coordinate systems in Creo Parametric.
Transforming Solid to Screen Coordinates
Functions Introduced:
The view matrix describes the transformation from solid to screen coordinates. The function ProViewMatrixGet() provides the view matrix for the specified view. Example 1: Solid Coordinates to Screen Coordinates shows a function that transforms a point, using theProViewMatrixGet() function, and an example user function.
The function ProViewMatrixSet() changes the orientation of the solid model on the screen.
Example 1: Solid Coordinates to Screen Coordinates
The sample code in the file UgFundSolid2Screen.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_fundament shows how to transform solid coordinates to screen coordinates.
Example 2: Transform from Solid Coordinates to Screen Coordinates
The sample code in the file UgFundCsysTrf.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_fundament shows how to extract a selected point from the surface of a solid model, transform it from solid coordinates to screen coordinates, write the results into a file and display it.
Transforming Screen to Window Coordinates
Functions Introduced:
Transformation from screen to window coordinates consists solely of a zoom factor and pan in X and Y.
The function ProWindowCurrentMatrixGet() gets the transformation matrix for the window. A pan and zoom transformation matrix consists of:
•  The scale factor, running down the diagonal of the matrix. For example, to zoom in by a factor of 2, the value 2.0 will be down the diagonal in the elements (0,0), (1,1), and (2,2).
•  The translation factor (pan) in the elements (3,0) - X and (3,1) - Y.
•  The element at (3,3) should be 1.0.
The function ProWindowPanZoomMatrixSet() can change the pan and zoom of the window. The matrix should contain only the elements listed above, for function ProWindowCurrentMatrixGet().
Transforming from Drawing View to Screen Coordinates in a Drawing
Function Introduced:
The function ProDrawingViewTransformGet() performs the transformation from drawing view coordinates (solid) to screen coordinates. It describes where a particular point on the solid will be in the drawing for a particular view of the solid.
Transforming from Screen to Drawing Coordinates in a Drawing
Function Introduced:
The function ProDrawingSheetTrfGet() returns the matrix that transforms screen coordinates to drawing coordinates. The function performs this transformation for the first sheet.
Example 3: Screen Coordinates to Drawing Coordinates
The sample code in the file UgFundScreen2Drw.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_fundament allows you to transform the screen coordinates to drawing coordinates.
Example 4: Transform from Screen Coordinates to Drawing Coordinates
The sample code in the file UgFundCsysTrf.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_fundament allows you to select a point from the screen, transform it from screen coordinates to drawing coordinates, write the results into a file and display it.
Transforming Coordinates of an Assembly Member
Function Introduced:
The function ProAsmcomppathTrfGet() provides the matrix for transforming from the solid coordinate system of the assembly member to the solid coordinates of the parent assembly, or the reverse.
Transforming to Coordinate System Datum Coordinates
Functions Introduced:
The function ProCsysDataGet() provides the location and orientation of the coordinate system datum in the solid coordinate system of the solid that contains it. The location is in terms of the directions of the three axes, and the position of the origin. When these four vectors are made into a transformation matrix using the function ProMatrixInit(), that matrix defines the transformation of a point described relative to the coordinate system datum back to solid coordinates. To transform the other way, which is the more usual requirement, you need to invert the matrix. The example function ProUtilMatrixInvert(), inverts the specified matrix.
Transforming Coordinates of Sketched Entities
Function Introduced:
The function ProSectionLocationGet() provides the matrix for transforming from the solid coordinate system to the sketch coordinate system, or the reverse.
Example 5: Using Several Coordinate Transforms
The sample code in the file UgGraphZoomAtPoint.c located at <creo_toolkit_loadpoint>/protk_appls/pt_userguide/ptu_graphics demonstrates how to use several coordinate transformations. The function will zoom in on a solid model, with the results centered at the selected location.