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 & HelpSyntax Questions › 3D surface sketches
Page Index Toggle Pages: 1
3D surface sketches (Read 403 times)
3D surface sketches
Jan 3rd, 2009, 8:04pm
 
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);
}
}
Re: 3D surface sketches
Reply #1 - Jan 3rd, 2009, 8:46pm
 
Hi.

i have a 3d perlin surface rendered using quad strips.
here: http://rui-m.com/p5/perlinsurface/

hope its somewhat helpful

Rui
Page Index Toggle Pages: 1