How to transform lon-lat-heading to sprite xyz rotation

noonanon's picture

Hey I dont know if this is the right proccess to get what im trying to achieve so maybe its better to explain what i want the end result to be.

Basicly I need to work out how to make a sprite located at a specific lon/lat coordinate have the same orientation as the spheres normal direction at that point, so when I view that target co-ordinate (with GL Look at) the sprite will appear to face me straight on. I know I could probably use GL inverse rotation (broken for now) to get a similar effect but it would mean any other location i am transitioning to would end up facing towards me also.

I've attempted to use dusts quaternion to euler angles patch but there is something im missing (Art school really didnt help me hone my math skill) and I dont think I've fully grasped this 4d stuff yet. Anyone point out what im doing wrong?

lat:long to xyz rotation.qtz525.25 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

fsk's picture
Re: How to transform lon-lat-heading to sprite xyz rotation

i cant open your patch. prolly QC4. but i do have what you need:).

it took me quite a while to get this thing together. needed it to align something to a curve. got a bit of help from the responses on this thread forgot to say thanx :/. thanx guys:).

anyway, what the angles javascript does is something like the look at patch. the first point (x1,y1,z1) is the up point (not a vector) the second one is the eye point and the third one is the point you want to look at. the angles are in radians, so youll have to convert from degrees, but that shouldnt be a problem.

i left another similar patch in there if someone needs it. it can be used to make a look at macro if you combine it with a 3d transform.


longitude latitude.qtz11.56 KB

noonanon's picture
Re: How to transform lon-lat-heading to sprite xyz rotation

Hey that is super usefull, seems to work just as described. Added bonus is that I dont have to use that buggy look at patch - was preventing me using glsl shaders:)

cheers Fsk