Skip to main content
2-Explorer
January 9, 2018
Solved

Transformation matrix of two csys

  • January 9, 2018
  • 10 replies
  • 6237 views

Hello

I am aware how to find transformation matrix using API for a component of assembly using Toolkit.

Is this possible to find transformation matrix between two csys using Toolkit API? If yes, what should be the API or approach for same.

Any thought will be of great help.

Thanks and Regards
Ketan

Best answer by FV_01
Hi all, Pro/Toolkit User Guide has a chapter 'Transforming to Coordinate System Datum Coordinates' - the basic steps are outlined there. This is how one would do it without using cursory online search: Get ProCsys from ProFeature using ProFeatureGeomitemVisit and ProGeomitemToCys or ProCsysInit or ProSolidCsysVisit whatever is more convinient. Having ProCsys handle - get ProGeomitemdata with ProCsysDataGet - this data has everything for determining transformation from coordinate system in question to a model reference frame. Create a matrix (from csys to model frame) using ProMatrixInit( geomdata->data.p_csys_data->x_vector, geomdata->data.p_csys_data->y_vector, geomdata->data.p_csys_data->z_vector, geomdata->data.p_csys_data->origin ); Repeat those steps for another coordinate system. The rest is an excercise of matrix multiplications and inversions - the functions for matrix manipulation are in Pro/Toolkit examples 'UtilMatrix.c' file. it would be a good idea to pay attention to matrix multiplicaiton order A * B is not equal to B *A - turn left and make three steps forward would end being in a quite different location comparing to three steps forward and turn left... HIH. FV.

10 replies

KenFarley
21-Topaz II
January 9, 2018

A cursory online search finds that there doesn't seem to be a function in the Toolkit API to calculate a transformation matrix. So, you'll likely have to delve into the linear algebra necessary to write your own function, or there is probably a linear matrix algebra library available for your language. You'll just have to find a non-toolkit solution.

FV_01
FV_0117-PeridotAnswer
January 9, 2018
Hi all, Pro/Toolkit User Guide has a chapter 'Transforming to Coordinate System Datum Coordinates' - the basic steps are outlined there. This is how one would do it without using cursory online search: Get ProCsys from ProFeature using ProFeatureGeomitemVisit and ProGeomitemToCys or ProCsysInit or ProSolidCsysVisit whatever is more convinient. Having ProCsys handle - get ProGeomitemdata with ProCsysDataGet - this data has everything for determining transformation from coordinate system in question to a model reference frame. Create a matrix (from csys to model frame) using ProMatrixInit( geomdata->data.p_csys_data->x_vector, geomdata->data.p_csys_data->y_vector, geomdata->data.p_csys_data->z_vector, geomdata->data.p_csys_data->origin ); Repeat those steps for another coordinate system. The rest is an excercise of matrix multiplications and inversions - the functions for matrix manipulation are in Pro/Toolkit examples 'UtilMatrix.c' file. it would be a good idea to pay attention to matrix multiplicaiton order A * B is not equal to B *A - turn left and make three steps forward would end being in a quite different location comparing to three steps forward and turn left... HIH. FV.
KenFarley
21-Topaz II
January 10, 2018

Touche.

I figured it might be simple enough to use the mathematical libraries that have matrix manipulation routines, since the results I found on a search seemed to indicate that a simple "get transformation matrix" function wasn't evidently available. I also didn't know what language the initial poster was using. I've written such routines in the past and it's nothing very difficult when we're dealing with three dimensions.

16-Pearl
January 10, 2018

In Creo Toolkit you can get the transformation matrix for

1. Assembly to Part / Part To Assembly (CSYS) usingProAsmcomppathTrfGet

ProAsmcomppathTrfGet

2. Drawing sheetProDrawingSheetTrfGet

ProDrawingSheetTrfGet
2-Explorer
January 10, 2018

Thank you all for your valuable response. 

14-Alexandrite
February 15, 2018

My experience is that the linear algebra for this stuff can be a bit of a pain, and as others have mentioned, it definitely requires a bit of attention to detail. 

 

For example, coordinates returned via ProCsysDataGet() (or pfcCoordSystem_ptr->GetCoordSys() in OTK) returns the coordinates in a way that I typically find to be the exact OPPOSITE of what I typically need, so I almost always end up needing to take the inverse of the matrix.

Similarly, ProAsmcomppathTrfGet is useful to get the transformation from the "desired part" to the "top assembly"... but its never quite that simple.

 

I often find that if I need to find how "CSYS A" in "Y.PRT" is related to "CSYS B" in "Z.PRT", often times I need to run through the logic of:

  • ProCsysDataGet to get matrix from "CSYS A" to default csys of "Y.PRT"
  • ProAsmcomppathTrfGet  to go "upward" from the local csys of "Y.PRT" to the top of the tree
  • ProAsmcomppathTrfGet  to go "downward" from the top of the tree to the local csys of "Z.PRT"
  • ProCsysDataGet to get from the local csys of "Z.PRT" to "CSYS B"

 

FYI - there ARE some free libraries out there like Eigen and Ogre3D which can help with some of the heavy lifting. I can't say I've ever used them... but I've certainly thought about it several times 🙂

Hope this helps!

Thanks, 
James Sullivan