Registered Member
|
Hello. I've seen one mailing list post regarding this, but it flew a bit over my head.
I center the MarbleWidget on a vehicle image that I paint on the map that is updating live. Rather than rotate the vehicle image as its heading changes, I'd like to rotate the map around the vehicle so the vehicle is constantly pointing upwards. I'm zoomed in far enough that the projection doesn't matter. I did notice the MarbleWidget::rotateBy() method, but of the two that are defined, I assume I'll need to use the one with quaternions. I have a very limited understanding of quats (i.e. I read the wikipedia article) and can't quite reason out what to do. Any help would be greatly appreciated! Thank you. |
Registered Member
|
The more I read up, the less it sounds like I should be using MarbleWidget::rotateBy(). Perhaps a better solution is to change the MarbleWidget::viewPort()->planetAxis(). But that still involves quats and every time I try playing with it I get a garbage result.
|
KDE Developer
|
Hi,
Yes the proper way would be to adjust the planetAxis (since the extra parameter in the old rotateBy API got removed), In ViewportParams there is the implementation of centerOn() which has this snippet: Quaternion axis = Quaternion::fromEuler( -lat, lon, 0.0 ); axis.normalize(); d->setPlanetAxis( axis ); IIRC You just need to replace "0.0" by the value you want to get the proper axis. |
Registered Member
|
UPDATE: Previous edit used lat and lon in wrong order. It is correct here.
Thank you Tackat-- the people in IRC said you'd be able to help me . However, while this method is rotating the world, it's not quite the way I would like. The first thing to note is that we seem to be referring to slightly different versions-- I'm using the packaged source from the website, 1.2.0. The first question is, should I instead be using the trunk from git? Knowing that I'm using that version, I can still work with what you said. I think it would be easiest if I supplied a few screenshots of what's happening. I'm in the U.S.A., say the middle of Kansas (in radians, lat = 0.664366428, lon = -1.74950509). I have the following program:
That results in a picture like this (which obviously looks fine): Now I change the code to this:
and nothing changed (which was what I expected with 0.0). Getting excited, I changed the 0.0 to M_PI/2.0 and got this: What I really wanted with M_PI/2.0 was the world to rotate as in this image (ignore the fact that the compass etc. is also rotated ): I have a feeling this will need some quat math... what do you think? |
Registered Member
|
Sorry, I realized that my previous post had some errors (I flipped lat and lon around in the call to createFromEuler()). It has been updated.
|
Registered Member
|
Hi!
Wanted to do the same thing, but it seems that the methods you used (specially setPlanetAxis) are not usable any more (changed from public to private in 1.3). How do you solve the problem now? I didnt find any replacement? |
Registered Member
|
Ok, as far as i have seen this feature as been removed completly, cause rotation around z-axis should is not supported (yet)
|
Registered Member
|
kreuzberger: I'm sorry to say I never did solve this problem; I would have marked it as such. setPlanetAxis() never worked the way I hoped anyway. |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell