Hi Paul,

Thanks for your reply. I need only one explanation about that;

//////////////////////////////////////////////// psudo code
Matrix model= identity;
Matrix matrix1= identity;
matrix1->rotate( 10 degree on LOCAL X axis )
matrix1->rotate( 10 degree on LOCAL Y axis )
matrix1->rotate( -10 degree on LOCAL X axis )
matrix1->rotate( -10 degree on LOCAL Y axis )

model->setMatrix( matrix1 )

matrix1 is NOT IDENTITY at last.
//////////////////////////////////////////////////

Do you think it is impossible rotating due to 2 different LOCAL axis on same
matrix?

I have tried your suggestion but can't resolve;

//////////////////////////////////////////////// psudo code
Matrix model= identity;
Matrix matrix1= identity;
Matrix matrix2= identity;

matrix1->rotate( 10 degree on LOCAL X axis )
model->setMatrix(matrix1 * matrix2);  // Turned Local X axis 10 degree

matrix2->rotate( 10 degree on LOCAL Y axis )
model->setMatrix(matrix1 * matrix2);  // Turned Global Y axis 10 degree

matrix1->rotate( -10 degree on LOCAL X axis )
model->setMatrix(matrix1 * matrix2);  // Turned Local X axis -10 degree

matrix2->rotate( -10 degree on LOCAL Y axis )
model->setMatrix(matrix1 * matrix2);  // Turned Global Y axis -10 degree

model is IDENTITY at last.
//////////////////////////////////////////////////

As you said I hold different rotation Matrix for each Axis, but as you can
see from above code some rotations done on LOCAL and some rotations done on
GLOBAL axis. But I want to do all rotations on LOCAL axis without any
artifacts. I know below formulation;

///////////////////////////////////////////////////
m = rotation * m;  // rotate around matrix axis (local space)
m = m * rotation;  // rotate around fixed axis (global space)
///////////////////////////////////////////////////

But if I change " model->setMatrix(matrix1 * matrix2); " formulation for Y
Axis to " model->setMatrix(matrix2 * matrix1); ", this time as a result some
frame jumping occured on rotation operations.

Do you think it is impossible to operate absolute matrix multiplication for
2 different Local axis on one model?

If I operate incremental matrix multiplication for 2 different Local axis I
can rotate my model pretty easy but this time I might not reach initial
rotation state for this model although I rotate reverse direction for each
axis but in different order.

Am I trying to achieve impossible operation or not?
Thanks so much. Regards.

Ümit Uzun


30 Aralık 2009 23:48 tarihinde Paul Martz <pma...@skew-matrix.com> yazdı:

> I would store the x and y rotations as separate variables. Use them to
> compute a single Matrix when you need to update. Test for identity by
> checking to see if your x and y variables fall within an epsilon range of
> zero.
>
> Paul Martz
> Skew Matrix Software LLC
> _http://www.skew-matrix.com_ <http://www.skew-matrix.com/>
> +1 303 859 9466
>
>
>
> Ümit Uzun wrote:
>
>> Hi All,
>>
>> I have a problem about rotating one MatrixTransform node with 2 different
>> Matrix which one of responsible for rotation on X by osg::X_AXIS and one of
>> responsible for rotatin by osg::Y_AXIS.
>> I have done some rotation to MT node but after this operations I am
>> waiting to get Identity matrix for MT which has Identity matrix in initial
>> state.
>> Some psudo codes;
>>
>> -------------------------------------------------
>> // Initial states
>> osg::MatrixTransform* MT;
>> MT->setMatrix( osg::Matrix::identity() );
>> osg::Matrix ang1 = osg::Matrix::identity();
>> osg::Matrix ang2 = osg::Matrix::identity();
>>
>> // Updates done with this codes
>> ang1.preMult(osg::Matrix::rotate(osg::Quat(osg::DegreesToRadians(10.0f),
>> osg::X_AXIS)));
>> ang2.preMult(osg::Matrix::rotate(osg::Quat(osg::DegreesToRadians(10.0f),
>> osg::Y_AXIS)));
>>
>> MT->setMatrix(ang2 * ang1);
>> -------------------------------------------------
>>
>> if I rotate my MT by above code; model rotated on Y by localCoordinate
>> axis and rotated on X fixedCoordinate axis. But I wanted to rotate on X
>> local coordınate axis too.
>>
>>
>> If I use one matrix to update rotation;
>> -------------------------------------------------
>> // Initial states
>> osg::MatrixTransform* MT;
>> MT->setMatrix( osg::Matrix::identity() );
>> osg::Matrix ang1 = osg::Matrix::identity();
>>
>> // Updates done with this codes
>> ang1.preMult(osg::Matrix::rotate(osg::Quat(osg::DegreesToRadians(10.0f),
>> osg::X_AXIS)));
>> ang1.preMult(osg::Matrix::rotate(osg::Quat(osg::DegreesToRadians(10.0f),
>> osg::Y_AXIS)));
>> ang1.preMult(osg::Matrix::rotate(osg::Quat(osg::DegreesToRadians(-10.0f),
>> osg::X_AXIS)));
>> ang1.preMult(osg::Matrix::rotate(osg::Quat(osg::DegreesToRadians(-10.0f),
>> osg::Y_AXIS)));
>>
>> MT->setMatrix(ang1);
>> -------------------------------------------------
>>
>> With above code I can rotate my model X and Y local coordinate axis. But
>> this code has lack too.
>>
>> After apply positive and negative way rotation I am waiting to get
>> IdentityMatrix but after all rotation operation my MT->getMatrix() give me
>> different from IdentityMatrix. I think I should use inverse matrix instead
>> of negative direction rotated matrix to rotate -X or -Y direction. Could it
>> solve my problem or not?
>>
>> By these 2 rotation operations my main goal is that; I want to rotate MT
>> by X and Y local coordinate system. And after all rotations I can get
>> initial state of MT. I mean I apply to many rotation transformation to my
>> unique node and after all dual(for X and -X or for y and -Y with unordered
>> queue) operation I want to get first initial matrix for my MT node.
>>
>> I know this is not hard operations, but I am unstable about choosing which
>> one is right way.
>> I appreciate any comments.
>> Regards.
>>
>> Ümit Uzun
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to