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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Rotate model using toolkit

Ketan_Lalcheta
19-Tanzanite

Rotate model using toolkit

Hello

 

We would like to rotate model by 90 degree with respect to Y axis. I am using below code :

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);


//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = cos(1.5707);
objMatrixAboutY[0][1] = 0;
objMatrixAboutY[0][2] = -sin(1.5707);
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = 0;
objMatrixAboutY[1][1] = 1;
objMatrixAboutY[1][2] = 0;
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = sin(1.5707);
objMatrixAboutY[2][1] = 0;
objMatrixAboutY[2][2] = cos(1.5707);
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

 

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

 

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

 

 

This code just rotate the default csys orientation in to creo window. Model is not rotated at all. Am i missing some information? What should be done to rotate model as well?

 

Thanks and Regards

Ketan

1 ACCEPTED SOLUTION

Accepted Solutions
FV
17-Peridot
17-Peridot
(To:Ketan_Lalcheta)


status = ProViewRotate( objTopAssembly, NULL, PRO_Y_ROTATION, 90);		
@Ketan_Lalcheta wrote:

Hello

 

We would like to rotate model by 90 degree with respect to Y axis. I am using below code :

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);


//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = cos(1.5707);
objMatrixAboutY[0][1] = 0;
objMatrixAboutY[0][2] = -sin(1.5707);
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = 0;
objMatrixAboutY[1][1] = 1;
objMatrixAboutY[1][2] = 0;
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = sin(1.5707);
objMatrixAboutY[2][1] = 0;
objMatrixAboutY[2][2] = cos(1.5707);
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

 

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

 

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

 

 

This code just rotate the default csys orientation in to creo window. Model is not rotated at all. Am i missing some information? What should be done to rotate model as well?

 

Thanks and Regards

Ketan


 

View solution in original post

8 REPLIES 8

You should get model transformation matrix and update it than set it.

Yes, but I thought it is required for panning only. 

 

If you refer example given with API, it seems only last row related to panning is required to get transferred with respect to different matrix. Could you please help me with what should be done to give it a try?

 

I know we need to get matrix and got it using ProViewMatrixGet() API. what next? I don't have point to transfer with respect to this matrix. I have 4*4 matrix for rotation about X axis.

I tried below code:

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);

ProMatrix objBaseMatrix;
status = ProViewMatrixGet(objTopAssembly,NULL,objBaseMatrix);

ProPoint3d objLine1 = { cos(1.5707) ,0,-sin(1.5707) };
ProPoint3d objLine2 = { 0 ,1,0 };
ProPoint3d objLine3 = { sin(1.5707) ,0,cos(1.5707) };

status = ProPntTrfEval(objLine1, objBaseMatrix, objLine1);
status = ProPntTrfEval(objLine2, objBaseMatrix, objLine2);
status = ProPntTrfEval(objLine3, objBaseMatrix, objLine3);

//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = objLine1[0];
objMatrixAboutY[0][1] = objLine1[1];
objMatrixAboutY[0][2] = objLine1[2];
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = objLine2[0];
objMatrixAboutY[1][1] = objLine2[1];
objMatrixAboutY[1][2] = objLine2[2];
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = objLine3[0];
objMatrixAboutY[2][1] = objLine3[1];
objMatrixAboutY[2][2] = objLine3[2];
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

This at least makes some changes and assembly (not even a single portion) is not visible at all in window. But I was expecting assembly to be rotated by 90 degree w.r.t. Axis.

 

Any idea would be of great help.

Change only Angle values

set matrix using API ProViewMatrixSet

Following is the calculation for Angle

xR, yR and zR are angles.

 

To rotate model 90 degree with respect to Y position , pass following values.

xR = 0.0;

yR = 9.0;

zR = 0.0;

//Manupilate to Radian

double xAngle = degreetoRadian(xR);

double yAngle = degreetoRadian(yR);

double zAngle = degreetoRadian(zR);

 

 

//Build matrix here..

ProMatrix matrix;

matrix[0][0] = cos(yAngle) * cos(zAngle);

matrix[0][1] = -cos(yAngle) * sin(zAngle);

matrix[0][2] = sin(yAngle);

matrix[0][3] = 0;

matrix[1][0] = cos(xAngle) * sin(zAngle) + cos(zAngle) * sin(xAngle) * sin(yAngle);

matrix[1][1] = cos(xAngle) * cos(zAngle) - sin(xAngle) * sin(yAngle) * sin(zAngle);

matrix[1][2] = -cos(yAngle) * sin(xAngle);

matrix[1][3] = 0;

matrix[2][0] = sin(xAngle) * sin(zAngle) - cos(xAngle) * cos(zAngle) * sin(yAngle);

matrix[2][1] = cos(zAngle) * sin(xAngle) + cos(xAngle) * sin(yAngle) * sin(zAngle);

matrix[2][2] = cos(xAngle) * cos(yAngle);

matrix[2][3] = 0;

 

 

// Do not use this code if you do not want to set Distance

matrix[3][0] = xDist;

matrix[3][1] = yDist;

matrix[3][2] = zDist;

matrix[3][3] = 1;

 

 

 

double degreetoRadian(double degree)

{

return degree * PI / 180;

 

}

Okay cool... Will give this a try tomorrow for sure....

Few questions :
No panning require ... So, x , y and z distance should be one or zero?

Only matrix for windows zoom pan is required to set or view matrix is also required to be set ?

Appreciate your help and responses on this issue.

Sorry but Could not get what you mean to say by change only angle values....

Proviewmatrixset for default view and default model i.e. first two arguments as Null sets model being rotated.... This does not require any transformation at all... It just can't set standard orientation but rotation is observed.... Orientation is disturbed and main question is that why this API need to be used for setting model as rotated ? Zoom at a point worked with single API of windows zoom pan set....

FV
17-Peridot
17-Peridot
(To:Ketan_Lalcheta)


status = ProViewRotate( objTopAssembly, NULL, PRO_Y_ROTATION, 90);		
@Ketan_Lalcheta wrote:

Hello

 

We would like to rotate model by 90 degree with respect to Y axis. I am using below code :

 

ProError status = PRO_TK_GENERAL_ERROR;

//Get assembly
ProMdl objTopAssembly;
status = ProMdlCurrentGet(&objTopAssembly);

//get current assembly's window
int intWindowID;
status = ProMdlWindowGet(objTopAssembly, &intWindowID);


//Matrix to rotate 90 degree about Y axis
ProMatrix objMatrixAboutY;
objMatrixAboutY[0][0] = cos(1.5707);
objMatrixAboutY[0][1] = 0;
objMatrixAboutY[0][2] = -sin(1.5707);
objMatrixAboutY[0][3] = 0;

objMatrixAboutY[1][0] = 0;
objMatrixAboutY[1][1] = 1;
objMatrixAboutY[1][2] = 0;
objMatrixAboutY[1][3] = 0;

objMatrixAboutY[2][0] = sin(1.5707);
objMatrixAboutY[2][1] = 0;
objMatrixAboutY[2][2] = cos(1.5707);
objMatrixAboutY[2][3] = 0;

objMatrixAboutY[3][0] = 0;
objMatrixAboutY[3][1] = 0;
objMatrixAboutY[3][2] = 0;
objMatrixAboutY[3][3] = 1;

 

// set new matrix
status = ProWindowPanZoomMatrixSet(intWindowID, objMatrixAboutY);

 

//Repaint the window
status = ProWindowRepaint(intWindowID);

 

 

 

This code just rotate the default csys orientation in to creo window. Model is not rotated at all. Am i missing some information? What should be done to rotate model as well?

 

Thanks and Regards

Ketan


 

Top Tags