For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Rotating around local point using global coordinates

Jure Jesenšek's picture
Forums: 

Hi, I'm trying to rotate the model I have (currently by rotating the view), both by mouse (using V3d_View.StartRotation() and V3d_View.Rotation()) and "programmatically", by specifying the axis and degrees (using V3d_View.Rotate(axis, degrees)). The rotation by mouse works as expected. But I'm having some difficulties getting the "programmatic" rotation to work as I would expect it do work, when in combination with moving and/or rotation by mouse.

So I started the programmatic rotation by only specifying the axis and degrees of the rotation (V3d_View.Rotate(axis, degrees)), but in this way, the model was being rotated around the center of the screen, not around the center of gravity of the model or the (0,0,0) point, which became apparent when the model is moved away from the center of the screen. I solved this problem by adding the point of rotation to the Rotate(...) function (V3d_View.Rotate(axis, degrees, 0, 0, 0)).

But then I realised that the axis of rotation (the first parameter of Rotate(...)) was the "local" axis, not a "global" axis. This meant that rotating around an axis was performed relative to the model, and not relative to the viewer/user. Thus rotating around, lets say axis Z, could mean that the model was rotated in a clock-wise direction in one position (relative to the viewer/user), but in a counter-clock-wise direction if the model was rotated by 180° around another axis.

My question is, is there an easy-ish way to make the rotation direction consistent and always the same, relative to the viewer, regardless of the orientation of the model? In other words, can I rotate the model around a point in the "local" coordinate system, but using "global" coordinates (X, Y, Z)? This rotation would be similar to rotation by mouse, where by moving the mouse in one direction (lets say, right) always rotates the model in the same direction, relative to the viewer.

Thank you in advance.