coordinate system conversion
Members - Reputation: 106
Posted 18 May 2012 - 09:24 AM
i am trying to build my own simulator and i am using some of flightgears methods and concepts.
i have trouble understanding something.
flight gear uses cartesian coordinate system (The X axis runs along a line from the center of the earth out to the equator at the zero meridian. The Z axis runs along a line between the north and south poles with north being positive. The Y axis is parallel to a line running through the center of the earth out through the equator somewhere in the Indian Ocean). origin is the center of the earth.
now, in my program i want my origin to be my camera position (0,0,0).
how to convert cartesian to XNA coordinate system?
Members - Reputation: 565
Posted 18 May 2012 - 03:01 PM
XNA doesn't necessarily follow a specific coordinate system, but for 99% of all examples on the internet the "XNA" coordinate system is a cartesian coordinate system. A cartesian coordinate system is simply a coordinate system where the X/Y/Z coordinates define locations along the cardinal directions (generally) right/up/forward. I recommend you give http://en.wikipedia....ordinate_system a glance.
Even so, I recommend against defining the origin around your camera. Assuming your camera moves, you won't want to constantly redefine the locations of every object in the world in relation to your camera. That code would be harder and much less efficient. I also recommend you look for a basic introduction to vector math and matrix transformations.
Edit: Also, are the lines you mention straight or wrapped around the planet? If they are wrapped, you are talking about a polar coordinate system.
Edited by DementedCarrot, 18 May 2012 - 03:04 PM.
Members - Reputation: 106
Posted 18 May 2012 - 09:10 PM
The problem is, when I convert my lat,long,altitude position of my camera location to cartesian system the flightgear uses i get some big value(from my head 451322,461325,12453).... I want this to be 0,0,0. And everything else in game positioned relative to my camera.. What are the correct calculations (transformations)?
Prime Members - Reputation: 683
Posted 19 May 2012 - 05:56 AM
I'm not sure I understand what you mean :
My camera is sort of "static". You can just look around with camera, no [...] rotation.
Looking around with camera implies rotating camera, isn't it ?
And if you rotate your camera, you'd have to recompute the locations of the objects, even if the camera stays always at (0,0,0) (because you work in view-space)
I'd suggest you to work in world-space instead, and follow DementedCarrot advice about getting basis about transformations : you'll need this knowledge sooner or later.
Posting your code may help to understand what you want to achieve ?
Edited by NicoLaCrevette, 19 May 2012 - 06:15 AM.