How to move particle on sphere

This topic is 2060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have a particle where I know:

1. position (either in euclidean or spherical coordinates)
3. speed (linear distance).

How do one calculate next position for the particle?

Share on other sites

Weird. I just answered a question about quaternions that is essentially the same question.

If your time step is small, move the particle in R^3, forgetting about the sphere for a moment, then project back to the sphere. If that approximation is not good enough, there is a formula you can use that involves computing cosine and sine. I'll figure it out and post it, if you really need it.

Share on other sites

I don't know how to calculate forward in R^3 either. One solution I thought of is to rotate particle direction around sphere normal at particle position. Sound simple but I find matrix rotations hard. I don't understand how to write a "vector3.rotateAround(vector axis, float angle)"-function.

My velocities are probably small  but I don't know yet, I trying to simulate fluids and they have a tendency to blow up if not correct.

Right now I would settle for any algorithm that would help me progress.

Share on other sites

If (x,y,z) is a point on the surface of the unit sphere centered at the origin, the East vector is something like (z, 0, -x) and the North vector is something like (-xy/S, S, -yz/S), with S:=sqrt(1-y^2). You can then express your direction as North * cos(angle) + East * sin(angle).

I kind of rushed through the Math, so I am not 100% certain that the formulas are correct, but you can try to reproduce them yourself.

Share on other sites

I don't understand how to write a "vector3.rotateAround(vector axis, float angle)"-function.

It's very easy to do with quaternions. You just need to know how to construct the quaternion that represents the rotation you want, which is cos(angle/2) + sin(angle/2)*x*i + sin(angle/2)*y*j + sin(angle/2)*z*k, and how to rotate a point by the rotation represented by a unit-length quaternion, which is q' = q * v * conj(q).

Share on other sites

If (x,y,z) is a point on the surface of the unit sphere centered at the origin, the East vector is something like (z, 0, -x) and the North vector is something like (-xy/S, S, -yz/S), with S:=sqrt(1-y^2). You can then express your direction as North * cos(angle) + East * sin(angle).

I kind of rushed through the Math, so I am not 100% certain that the formulas are correct, but you can try to reproduce them yourself.

Really, thanks a lot!

I tried it and it works.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 11
• 23
• 42
• 75