cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

19-Tanzanite

## Transformation matrix of two csys

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

1 ACCEPTED SOLUTION

Accepted Solutions
17-Peridot
(To:KenFarley)
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 10
21-Topaz I
(To:Ketan_Lalcheta)

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.

17-Peridot
(To:KenFarley)
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.
21-Topaz I
(To:FV)

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.

19-Tanzanite
(To:KenFarley)
I am using C++... Do share if it is applicable to me
19-Tanzanite
(To:FV)
Planning to apply this methodology in toolkit tomorrow....

If A.asm has five levels of sub assembly like this: A.asm is main assembly which has B.asm. B.asm has C.asm. C.asm has D.asm and D.asm has E.asm. E.asm has part F.prt... Inturn, A.asm is top level assembly which has f.prt at level 6. What we need to find is transformation matrix between csys of A.asm and f.prt. If I find default csys of a.asm and f.prt, I will have two matrix one for each csys. Does these two matrix multiplication result into what I want that is transformation between a.asm and f.prt ??
21-Topaz I
(To:Ketan_Lalcheta)

Matrix wise it's just dividing the A matrix by the F matrix to get the transformation matrix from A to F to get T (or F to A?). Apparently this is determined by multiplying the A matrix by the inverse of the F matrix (or the F matrix by the inverse of the A matrix) You'll have to check to see which solution is the one that you will apply, but since multiplying A by T = F, it is easy to see that it's done right.

This seems like a good start: https://www.wikihow.com/Divide-Matrices

15-Moonstone
(To:Ketan_Lalcheta)

It's not too complicate
use
ProAsmcomppathTrfGet() and get transformation matrix.
Since ProAsmcomppath holds path details from Main assembly to sub level parts, It's simple with Creo Toolkit

Parthiban Kannan

15-Moonstone
(To:Ketan_Lalcheta)

In Creo Toolkit you can get the transformation matrix for

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

 ProAsmcomppathTrfGet

2. Drawing sheetProDrawingSheetTrfGet

 ProDrawingSheetTrfGet
Parthiban Kannan

19-Tanzanite
(To:PARTHIBAN_K)

Thank you all for your valuable response.

13-Aquamarine
(To:Ketan_Lalcheta)

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

President & Founder