Okay, here's a sketch that actually gets rendered. The idea here was to populate and array with the attractor set and then extend those points to the surface of a sphere. In theory, I'll do this by converting the x,y,z of each point into spherical coords(rho,phi,theta). Then, If I convert back to cartesian with a fixed value for rho, the second set of points SHOULD all live on a sphere, right? Anyway, here's the example. Doesn't quite look as it should. Gotta check my math.
Code:
import processing.opengl.*;
int ang;
sph2cart s2c;
cart2sph c2s;
attractor set1;
void setup(){
size(500,500,OPENGL);
s2c = new sph2cart();
c2s = new cart2sph();
set1 = new attractor(5000);
set1.popSet(-1.4,1.6,1,0.7,-1.3,0.67);
}
void draw(){
ambientLight(255,255,255,width/3,height/3,200);
translate(width/2, height/2);
// background(0);//
rotateY(radians(ang/3));
rotateX(radians(ang/2));
ang++;
makePoints();}
void makePoints(){
background(0);
stroke(255,127,255,120);
for(int i=0;i<set1.setLength();i++){
strokeWeight(2);
float x1=set1.getX(i)*height/5; float y1=set1.getY(i)*height/5; float z1=set1.getZ(i)*height/5;
float r=c2s.r(x1,y1,z1); float p=c2s.p(x1,y1,z1); float t=c2s.t(x1,y1,z1);
float x2=s2c.x(height,p,t); float y2=s2c.y(height,p,t); float z2=s2c.x(height,p,t);
beginShape(LINES);
vertex(x1,y1,z1);
vertex(x2,y2,z2);
endShape();
}
ang++;
}
class attractor{
// float a,b,c,d,e,f;
int points;
double bigX,bigY,bigZ;
float[] x;
float[] y;
float[] z;
float[][]xyz = {x,y,z};
attractor(int pointNb){
points = pointNb;
x = new float[points];
y = new float[points];
z = new float[points];
float[][]xyz_ = {x,y,z};
xyz = xyz_;
xyz[0][0] = 0;
xyz[1][0] = 0;
xyz[2][0] = 0;
}
void popSet(float a, float b, float c, float d, float e, float f){
int n;
for (int i=0; i<points; i++){
n = (i+1)%points;
//xyz[0][n]//
bigX = (Math.sin(a*xyz[1][i]))+ (c*(Math.cos(a*xyz[0][i])));
//xyz[1][n]//
bigY = (Math.sin(b*xyz[0][i]))+ (d*(Math.cos(b*xyz[1][i])));
//xyz[2][n]//
bigZ = (Math.sin(e*xyz[1][i]))+ (f*(Math.cos(f*xyz[1][i])));
xyz[0][n] = (float)bigX;
xyz[1][n] = (float)bigY;
xyz[2][n] = (float)bigZ;
}
}
int setLength(){
return(points);
}
float getX(int i){
return(xyz[0][i]);
}
float getY(int i){
return(xyz[1][i]);
}
float getZ(int i){
return(xyz[2][i]);
}
}
class cart2sph{
float r,p,t;
cart2sph(){
}
float r(float x,float y,float z){
r = sqrt((x*x)+(y*y)+(z*z));
return r;
}
float p(float x,float y,float z){
p = atan2(z, sqrt(x*x+y*y));
return p;
}
float t(float x,float y,float z){
t = atan2(y,x);
return t;
}
}
class sph2cart{
float x,y,z;
sph2cart(){
}
float x(float r,float p,float t){
x = r*cos(p)*cos(t);
return x;
}
float y(float r,float p,float t){
y = r*cos(p)*sin(t);
return y;
}
float z(float r,float p,float t){
z = r*sin(p);
return z;
}
}