1
votes

Recently i've been trying to equally distribute points over a 3d sphere surface, after some research this is my code in processing (java) :

import peasy.*;
PVector[] points_;

PVector[] generatePoints(int numberOfPoints){
    PVector[] points = new PVector[numberOfPoints];
    float gr = (float) (3-Math.sqrt(5));
    float lambda = PI * gr;
    
    for(int i=0; i<numberOfPoints; i++){
      float t = (float)i/numberOfPoints;
      float a1 = acos(1-2*t);
      float a2 = lambda * i;
      float x = sin(a1) * cos(a2);
      float y = sin(a1) * sin(a2);
      float z = cos(a1);
      PVector p = new PVector(x,y,z).mult(30);
      points[i] = p;
               
    }
    return points;
}


void setup(){
    
   size(600,600,P3D);
   PeasyCam cam = new PeasyCam(this,100);
   cam.setMinimumDistance(50);
   cam.setMaximumDistance(500);
   points_ = generatePoints(1000);
}
void draw(){

  background(0);
  stroke(255);
  strokeWeight(2);
  for(int i=0; i<points_.length; i++){
 
  point(points_[i].x,
        points_[i].y,
        points_[i].z);
  }
  
}

The thing is that the points are generated following a similar algorithm to the golden spiral one, so i can not do something like draw triangles based on the actual point, the next one and the one below... any ideas?

This is what I have.

this is what i have

This is what I want.

this is what i want

1
Congratulations on successfully distributing points uniformly on a sphere! A surprisingly high number of people fail at that task and then don't even realize they failed. I do not understand your sentence "i can not do something like draw triangles based on the actual point, the next one and the one below". Why can't you draw triangles?Stef
I could be misunderstanding what you want but can't you simply use beginShape() use your list of points to create the vertexes and let processing do the job of creating the triangles?statox
@Stef Hi! thanks for your comment, the problem is that the way the points are being generated in such a way that i can not join them easily, in other projects i did the points were stored in a 2d matrix in such a way that for the position m[i][j] i was able to join that point to the points m[i+1] and m[i][j+1] to form a triangle, like this "terrain simulation" i did time ago editor.p5js.org/LiaIndex/present/p9gP9cYS6 i was thinking in somehow for each point find the nearest points to it and join them.LiaIndex
@statox Hi!, unfortunately for the way the points are generated processing don't know how to join them correctly.LiaIndex
Quick update, the method i posted above doesn't work for a number of points greater than 18K sorry.LiaIndex

1 Answers

0
votes

seems like the term you're looking for is triangulation. In 2D you would mostly use Delaunay-Triangulation, as it yields very pretty triangles. I have never seen it used in 3D, but according to wikipedia there seems to exist a version of it for more than two dimensions (also MATLAB offers a toolbox with 3D Delaunay).