Hi,
I am trying to built nice 3D shapes using equations from XahLee's website.
I am able to plot the shapes in 3D but they are currently drawn using points. So obviously they are not the most beautiful in the way they look :)
I am interested to learn some tricks to make these shapes look more beautiful.
If you have any pointers to where I can look for inspiration, do let me know and I will try my best to make something more visually appealing with my code :)
Here is what I have so far (please wait a while for the shapes to come to life):
Code:
void setup(){
size(500, 500, P3D);
background(255);
Points3d = new Vector();
frameRate(36);
}
float r_step = 0.002;
float ry=0.0f;
void draw(){
background(255);
stroke(0);
translate(width/2.0, height/2.0, -200.0);
rotateY(ry);
ry += r_step;
float u = random(0, 2*PI);
float v = random(-2*PI, 2*PI);
float sc = 60;
float R=1; // radius of tube
float N=5.6; // number of turns
float H=4.5; // height
float P=1.4; // power
float L=4; // Controls spike length
float K=9; // Controls spike sharpness
float W = pow((u/(2*PI)*R), 0.9);
float x = sc*(W*cos(N*u)*(1+cos(v)));
float z = sc*(W*sin(N*u)*(1+cos(v)));
float y = sc*(W*sin(v)+L*pow((sin(v/2)), K)+pow(H*(u/(2*PI)),P));
if (Points3d.size() < 10000) Points3d.add(new Point3D(x, y, z));
for (int i=0; i < Points3d.size(); i++) ((Point3D)Points3d.get(i)).draw();
}
Vector Points3d;
class Point3D
{
float x, y, z;
Point3D (float _x, float _y, float _z)
{
this.x = _x; this.y = _y; this.z = _z;
}
void draw()
{
point(this.x, this.y, this.z);
}
}