Velocity/heading. Cartesian or spherical coordinates?

Started by
1 comment, last by codeToad 11 years, 11 months ago
I'm working on a game in Java using lwjgl for opengl. I'm working on designing my general "model" representation and I'm stuck trying to decide how I want to represent the heading/velocity of a model. Opengl uses Cartesian coordinates, but I' wondering if there's any reason I should store the model information natively as spherical coordinates... I can't figure out the pros and cons to it.

So I guess what I'm asking is, how does everyone else store the heading/velocity data for your models and why do you store it that way?
Advertisement
That depends on how you acquire the data and what you're going to use it for. Whatever the case, the velocity will need to be adjusted each time the position changes (assuming you're travelling around a sphere). What sort of game is it?

It's much harder to do things like line-of-sight or shortest path checks with spherical coordinates. The poles in particular are very annoying.
Does openGL provide methods for obtaining matrices that perform rotation, translation, and scaling? If so, they are going to have cartesian coordinates as their input/output. Even if you are making your own methods to do these things, it should be easy to google the mathematics necessary to do so. I don't know if it's even possible to perform transformations on spherical coordinates using matrix multiplication. (If it is, it'd be an interesting math lesson biggrin.png ).

This topic is closed to new replies.

Advertisement