Hi is anybody clever enough to explain to me why this program creates changing values , I realize that it resets the arrays with each draw loop , But why are they different ?
please format code with </> button * homework policy * asking questions
// TUBULAR FORM USING REFORMED ARRAYS ****** NIGEL S WOOLARD
int r = 100;
int r2 = 200;
int np = 12;
int cl = 100;
float angle=radians(360/np);
float anglestep = radians(360/np); // ALSO TRIED WITH PI VALUES
floatPX1 = new float [np];
floatPY1 = new float[np];
floatPZ1 = new float[np];
floatPX2 = new float[np];
floatPY2 = new float[np];
floatPZ2 = new float[np];
void setup() {
size(600, 600, P3D);
}
void draw() {
BACKGROUND();
CREATETUBE();
DRAWTUBE();
}
void CREATETUBE() {
noStroke();
beginShape(TRIANGLE_STRIP);
for (int i=0; i<np; i++) {
float px1 = sin(angle/np)*r;
float py1 = cos(angle/np)*r;
float pz1 = 0;
PX1[i] = px1;
PY1[i] = py1;
PZ1[i] = pz1;
//vertex (px1, py1, pz1);
float px2 = px1;
float py2 = py1;
float pz2 = pz1;
px2 = sin(angle/np)*r2;
py2 = cos(angle/np)*r2;
pz2 = 0+cl;
PX2[i] = px2;
PY2[i] = py2;
PZ2[i] = pz2;
// vertex (px2, py2, pz2);
angle = angle + anglestep;
}
endShape();
}
//****************************************************************************
void DRAWTUBE(){
translate(300,300,0);
beginShape();
for (int i=0;i<np;i++){
stroke(#FF0000);
vertex (PX1[i],PY1[i],PZ1[i]);
stroke(#FFEA00);
vertex (PX2[i],PY2[i],PZ2[i]);
}
endShape();}
//*****************************************************************************
void BACKGROUND(){
fill(#FF8000);
}