I have a particle where I know:

- position (either in euclidean or spherical coordinates)
- direction (360°/2 pi radians)
- speed (linear distance).

How do one calculate next position for the particle?

Started by Feb 24 2014 08:40 AM

,
5 replies to this topic

Posted 24 February 2014 - 10:33 AM

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.

Posted 24 February 2014 - 11:50 AM

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.

Posted 24 February 2014 - 12:14 PM

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.

Posted 24 February 2014 - 12:20 PM

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).

Posted 24 February 2014 - 12:31 PM

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.