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 › Undefined Class?
Page Index Toggle Pages: 1
Undefined Class?? (Read 390 times)
Undefined Class??
Mar 10th, 2009, 4:33pm
 
Can't seem to understand why? Seems to me like the Class is declared, and structured properly? Am I missing something with the operators?

Code:

int NUM_LINES = 1000;

Line pline;
ParticleLines plines;
float radius = 100;
int cx, cy;

void setup(){
size(800,800,P3D);

float theta = random(0,TWO_PI);
float u = random(-1,1);
pline = new Line(theta,u);
plines = new ParticleLines();

stroke(random(255),random(255),random(255));
frameRate(30);
}

void draw(){
background(0);
camera(0,0,500,0,0,0,0,1,0);

pushMatrix();
rotateY(map(mouseX,0,width,0,TWO_PI));
rotateX(map(mouseY,0,height,0,TWO_PI));
plines.update();
plines.render();
popMatrix();
}

class ParticleLines {
Line[] lines = new Line[NUM_LINES];

void ParticleLines(){
for(int i=0; i<NUM_LINES; i++){
float theta = random(0,TWO_PI);
float u = random(-1,1);
lines[i] = new Line(theta, u);
}
}

void update(){
for(int i=0; i<NUM_LINES; i++){
lines[i].update();
}
}

void render(){
for(int i=0; i<NUM_LINES; i++){
lines[i].render();
}
}
}


class Line {
float theta, u;
float vtheta, vu;
float x,y,z;

void Line(float _theta, float _u) {
theta = _theta;
u = _u;
vtheta = 0;
vu = 0;
}

void update(){
vtheta += random(-0.001, 0.001);
theta += vtheta;
if(theta<0 || theta>TWO_PI) vtheta *= -1;
vu += random(-0.001, 0.001);
u += vu;
if(u<-1 || u>1) vu *= -1;
vu *= 0.95;
vtheta *= 0.95;
x = radius * cos(theta) * sqrt(1-(u*u));
y = radius * sin(theta) * sqrt(1-(u*u));
z = u*radius;
}

void render(){
pushMatrix();
//translate(width,y,z);
line(0,0,0,x,y,z);
popMatrix();
}
}

Re: Undefined Class??
Reply #1 - Mar 10th, 2009, 5:31pm
 
That's not the class that is undefined, that's the constructor.
You declared a method of same name as your class, not a constructor.
Constructors has no return type, not even void.
Re: Undefined Class??
Reply #2 - Mar 10th, 2009, 5:36pm
 
oh I get it, it doesn't need a return type.
Page Index Toggle Pages: 1