OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

different result rotating Vec3d for Quat or Matrixd


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 355

PostPosted: Tue Jan 24, 2017 10:25 am    Post subject:
different result rotating Vec3d for Quat or Matrixd
Reply with quote

Hi,
may be this is a newbie question but I would like to understand the reason of this behaviour.

I have to calculate the coordinate of a 3D point wrt a different coordinate reference. The new coordinate reference is simply rotated wrt the first one. I tried two different implementations with different results.

osg::Vec3d eyeOffset(0.0, 0.0, 300.0);
osg::Quat rotation(osg::DegreesToRadians(0.0), osg::Z_AXIS, osg::DegreesToRadians(0.0), osg::Y_AXIS, osg::DegreesToRadians(45.0), osg::X_AXIS);
osg::Vec3d localEyeOffset = rotation * eyeOffset;
osg::Matrixd rotationMatrix(rotation);
osg::Vec3d localEyeOffset2 = rotationMatrix * eyeOffset;

I expected to have the same result for localEyeOffset and localEyeOffset2, while this is what I get:
localEyeOffset is (0.0, -212.132, 212.132)
localEyeOffset2 is (0.0, 212.132, 212.132)

Can you explain me why?

Regards,
Gianni
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Tue Jan 24, 2017 10:52 am    Post subject:
different result rotating Vec3d for Quat or Matrixd
Reply with quote

Hi,

Quote:
osg::Vec3d localEyeOffset2 = rotationMatrix * eyeOffset;



if you swap the order of the matrix and the vector will you get the same result?


On Tue, Jan 24, 2017 at 11:25 AM, Gianni Ambrosio <g.ambrosio+ ([email]g.ambrosio+[/email])> wrote:
Quote:
Hi,
may be this is a newbie question but I would like to understand the reason of this behaviour.

I have to calculate the coordinate of a 3D point wrt a different coordinate reference. The new coordinate reference is simply rotated wrt the first one. I tried two different implementations with different results.

osg::Vec3d eyeOffset(0.0, 0.0, 300.0);
osg::Quat rotation(osg::DegreesToRadians(0.0), osg::Z_AXIS, osg::DegreesToRadians(0.0),  osg::Y_AXIS, osg::DegreesToRadians(45.0), osg::X_AXIS);
osg::Vec3d localEyeOffset = rotation * eyeOffset;
osg::Matrixd rotationMatrix(rotation);
osg::Vec3d localEyeOffset2 = rotationMatrix * eyeOffset;

I expected to have the same result for localEyeOffset and localEyeOffset2, while this is what I get:
localEyeOffset is (0.0, -212.132, 212.132)
localEyeOffset2 is (0.0, 212.132, 212.132)

Can you explain me why?

Regards,
Gianni

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70034#70034





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 355

PostPosted: Tue Jan 24, 2017 3:19 pm    Post subject:
Re: different result rotating Vec3d for Quat or Matrixd
Reply with quote

Trajce Nikolov NICK wrote:

if you swap the order of the matrix and the vector will you get the same result?

Yes, same result but ...
1) that's pretty counterintuitive: why should I have to change the order to get the same result? And unfortunately I guess that's not documented.
2) if I really need to multiply the matrix on the left side then there isn't a similar way to get the same transformation with a quaternion since "Vec3d * Quat" gives a compile time error.

Regards,
Gianni
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts why does the adding of lighting shade... mirro General 0 Mon Feb 11, 2019 3:03 am View latest post
No new posts Disable auto rotating lyn General [forum] 2 Tue Jul 10, 2018 6:25 am View latest post
No new posts Can OSG be built to have Vec3 be a Vec3d Jason MacDonald General 1 Fri Feb 23, 2018 9:45 pm View latest post
No new posts Transformations using Quat and Mat mmaurus General 1 Tue Nov 14, 2017 2:42 pm View latest post
No new posts Rotating Slave Camera Views Jim Perkins General 1 Tue Sep 26, 2017 7:57 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP