Spherical Interpolation

Hi,

I’m playing around with particles and vectors, making a sphere out of them.

Now I want to make those particles move around the surface of the sphere - to do some spherical interpolation. All the documentations I found about this [incl. quaternion and slerp] were helpful, but I do not seem to be able to put my head around all this still.

Any documentation and/or examples recommendations would be great.

Thanks,

Hugues.

If I understand your problem correctly, you don’t need quaternions and spherical interpolation for what you are trying to do. What you need is a spherical-coordinate-system to translate motion on a fixed-radius “plane” to the surface of a sphere.

Quaternions are a compact and efficient way to encode rotations in 3D, to compose them in a way that avoids the “gimbal lock” artifacts that matrices sometimes produce, and to smoothly interpolate between them via spherical interpolation.

Hope this helps,
P.

hi.
i’ve done a few experiments on moving particles around in spheres. i usually work with ofxVec3f and to animate the particles i just mess around with the rotation and length of that vector. heres a pseudo example:

  
  
ofxVec3f myVec;  
float rotationX, rotationY, radius;  
  
//setup  
rotationX = ofRandom(0, 360);  
rotationY = ofRandom(0, 360);  
radius = 200;  
  
//update  
rotationX+=1;   
rotationY+=2;   
myVec.set(0, 0, radius);  
myVec.rotate(rotationX, rotationY, 0);  
  
  

hope that helps. i have a simple example where i was experimenting with spherical perlin noise flow fields that i can send you if you want.

I finally had the time to look at this.

[pangelo] As you proposed I went with a ‘spherical coordinate system’. The quaternions will be for another time.

[rui] thanks for sharing some of you code

Mabye I’m not understanding the question but the way I would do this is by restricting the particle’s movement to a sphere. If you already have a 3d particle system, then you just add two more checks:

if the particles are too close the the center of the sphere, move them away.

if the particles are too far from the center of the sphere, move them closer.