spherical coordinates

Started by
0 comments, last by mrcheesewheel 16 years, 11 months ago
hi all.. i'm developing a game that is going to involve playing on the surface of an invisible sphere, surrounding an object in the center. i've had much trouble coming up with proper mathematics to do this, using spherical coordinates isn't quite working out well enough. i think what i need is some way of computing the plane along the tangent of a point on the surface of the sphere (the 'current position') and computing the arc of motion, then using the points along that arc (recomputing if the velocity direction changes if so required at each stage)... but i'm a bit hazy on how to do this exactly.. any pointers, or some other method of accomplishing the same thing? thanks chris.
Advertisement
Exactly what you should do depends entirely on how you are implementing your system and how physically accurate you want it to be. If you have a look at lagrangian mechanics you'll see how to calculate the motion of a constrained particle (eg a bead on a wire). If you want to handle linear velocities, then (assuming the distance moved per frame is small compared to the sphere) you could simply consider the motion as linear and project it down onto the sphere. This works because a sphere is locally flat (this doesn't need real physics). If you want the player to be attached to the sphere by gravity, and you have a physics simulation, then you could have a genuine gravitational field attracting the player. None of this is mathematically that complex. I'm guessing the vector projecting method should be the simplest. You are simply storing cartesian coordinates in the normal way, with a coordinate system centred on the sphere, then normalising them to the spheres radius.
Hope this helps,

Dan

This topic is closed to new replies.

Advertisement