We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Cone Spread
Page Index Toggle Pages: 1
Cone Spread (Read 941 times)
Cone Spread
Oct 15th, 2009, 11:11am
 
I'm creating a 3d particle engine and am trying to implement a cone spread. My emitter has a direction associated with it using a custom spherical coordinate class I wrote:
Code:
class PVectorSphere {
 public float radius;
 public float inclination;
 public float azimuth;
 
 PVectorSphere(float r, float i, float a) {
   radius = r;
   inclination = i;
   azimuth = a;
 }
 
 public PVector toCartesian() {
   return new PVector(radius*sin(inclination - PI/2)*cos(azimuth), radius*cos(inclination - PI/2), radius*sin(inclination - PI/2)*sin(azimuth)); // A radius, inclination, and azimuth of (1, PI/2, 0) will return the positive y-axis.
 }
}


When the emitter emits its particles, it modifies its own direction as so:
Code:
directionRandomized = direction.get();
     directionRandomized.inclination += radians(random(-spread, spread));
     directionRandomized.azimuth += radians(random(-spread, spread));
     directionRandomized.normalize();


This works all well and fine except for the consequence of using spherical coordinates, which is that the point density increases towards the poles. This means that if the inclination is 90 degrees, the azimuth doesn't affect anything, and I don't get a cone. Does anyone have any insight on this? Thanks!
Page Index Toggle Pages: 1