FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Information Visualization
(Moderators: forkinsocket, REAS)
   globe distribution
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: globe distribution  (Read 1675 times)
5cameron

WWW
globe distribution
« on: Feb 25th, 2005, 1:26am »

Hi,
 
so I'm trying to wrap my mind around how to distribute a number of elements evenly over a globe.
 
I understand how to do it in 2d, over a circle its as simple as dividing 360 into the number of elements, and defining X, Y using COS and SIN.
 
but how would I do it in 3d??
 
thanks muchly in advance,
 
-cameron
 
fjen

WWW
Re: globe distribution
« Reply #1 on: Feb 25th, 2005, 9:55am »

see:
http://www.math.niu.edu/~rusin/known-math/95/sphere.faq
Quote:

Q1. What does it mean to place  N  points "evenly" on a sphere?
 
Well, what do you want it to mean? Several valid interpretations exist;
they lead to slightly different distributions of points.
 
...

 
some sources are here:
http://www.math.niu.edu/~rusin/known-math/index/spheres.html
 
i ported one of the sources from there before ... here it is:
Code:

/*
note: this will give you an exact amount of points (46) on the sphere,
if you need more then just subdevide the triangles it creates.
*/
// ported from basic code (sphere.bas).
// see the sphere-faq: http://www.math.niu.edu/~rusin/known-math/index/spheres.html
    //
    float K=6;
    float eps = 0.01;
    int N = 0;
 
    Point3D[] sp = new Point3D[46];
    sp[N] = new Point3D(100.0, 0.0, 0.0);
 
    for (int i=1; i<K; i++)
    {
 float M = round(2.0*K*sin(PI*(i/K)));
 for (int j=1; j<=M; j++)
 {
   N++; sp[N] = new Point3D(100.0, PI*(i/K), TWO_PI*(j/M));
 }
    }
    N++; sp[N] = new Point3D(100.0, PI, 0.0);
Code:

// POINT3D
 
class Point3D
{
  public float x; public float y;   public float z;
 
  public Point3D (float _x, float _y, float _z)
  {
    this.x = _x; this.y = _y; this.z = _z;
  }
}

 
i more or less "handcoded" the triangles .. like this:
    triangles = new Triangle3D[] {
 // upper cap
 new Triangle3D( sp[0], sp[1], sp[6] ),
 new Triangle3D( sp[0], sp[2], sp[1] ),
 new Triangle3D( sp[0], sp[3], sp[2] ),
 new Triangle3D( sp[0], sp[4], sp[3] ),
 new Triangle3D( sp[0], sp[5], sp[4] ),
 new Triangle3D( sp[0], sp[6], sp[5] ),
// row 1
...
// row 2
...
}
 
i'm sure there is a better way to do it though ...
 
i recommend looking into spherical coordinates which would give you a 2D + radius description of every point. then repel them until a certain distance-threshold is reached ...
 
/F
 
5cameron

WWW
Re: globe distribution
« Reply #2 on: Mar 4th, 2005, 2:21am »

wow, that stuff is intense! Still trying to soak it in.
 
I also found this which seems to be something:
 
http://mathworld.wolfram.com/SpherePointPicking.html
 
I wonder if there is a babelfish to convert mathmatician-speak into layman's terms?
 
THANKS!
 
-5
 
fjen

WWW
Re: globe distribution
« Reply #3 on: Mar 4th, 2005, 10:49am »

mathelfish ... i was hoping someone would come up with that!
 
/F
 
Pages: 1 

« Previous topic | Next topic »