Hi
I want to rotate one class of balls
I saw this
but still don't know how to deal with that if I have a class;
////////Here is my class code
class Station {
int radius;
int numberSt;
int xx, yy;
Station(int n, int centx, int centy, int rad) {
xx = centx;
yy = centy;
numberSt = n;
radius = rad;
ellipseMode(CENTER);
}
void display() {
float degreeInc = 2.0*( PI / numberSt);
int count = -1;
int[] pointsx = new int[ numberSt + 1];
int[] pointsy = new int[ numberSt + 1];
int smallRad = 10;
for ( float deg = 0; deg < 2*PI; deg = deg + degreeInc)
{
int dy = int(radius * sin(deg));
int dx = int(radius * cos(deg));
ellipse(xx+dx, yy+dy, smallRad, smallRad);
count++;
pointsx[count] = xx+dx;
pointsy[count] = yy+dy;
}
}
}
/////main code is
int numberSt=3;
int numStations =4;
Station[] stations= new Station[numStations];
void setup() {
size(600, 600);
background(0);
smooth();
ellipseMode(CENTER);
stations[0] = new Station(numberSt, 100, 100, 50);
stations[1] = new Station(numberSt, 300, 100, 50);
stations[2] = new Station(numberSt, 100, 300, 50);
stations[3] = new Station(numberSt, 300, 300, 50);
}
void draw() {
fill(0, 20);
rect(0, 0, width, height);
for (int i = 0; i <numStations; i++)
{
for (float c=0; c<2*PI; c+= 0.01){
pushMatrix();
translate(100,100);
rotate(c);
fill(255, 100);
stations[0].display();
popMatrix();
}
for (float c=0; c<2*PI; c+= 0.01){
pushMatrix();
translate(300,100);
rotate(c);
fill(255, 100);
stations[1].display();
popMatrix();
}
for (float c=0; c<2*PI; c+= 0.01){
pushMatrix();
translate(100,300);
rotate(c);
fill(255, 100);
stations[2].display();
popMatrix();
}
for (float c=0; c<2*PI; c+= 0.01){
pushMatrix();
translate(300,300);
rotate(c);
fill(255, 100);
stations[3].display();
popMatrix();
}
}
}
I try to put rotate(); inside the class, but didn't workout (-"-)