Translating and rotating
in
Programming Questions
•
2 years ago
I am really fed up with translating and rotating. Obviously I do not understand it.
Here is what I get from the following code :
I would like the flowers to rotate so that they all face the star properly, but I can't manage it.
Here is the code:
float cos18 = cos(radians(18));
float cos36 = cos(radians(36));
float cos54 = cos(radians(54));
float cos72 = cos(radians(72));
float sin18 = sin(radians(18));
float sin36 = sin(radians(36));
float sin54 = sin(radians(54));
float sin72 = sin(radians(72));
float longueur = 80;
float miniLongueur = 10;
float x;
float y;
fivePointedStar star = new fivePointedStar(10);
demiFleur miniFleur13 = new demiFleur(7, 13);
demiFleur miniFleur20 = new demiFleur(10, 20);
void setup()
{
size(1500,1200);
smooth();
//noStroke();
}
void draw() {
background(255);
translate(width/2, height/2);
translate(-200,-200);
pushMatrix();
scale(5, 5);
star.display();
figureEtoile();
popMatrix();
}
void figureEtoile()
{
for (int j = 0; j < 5; j= j + 1)
{
switch(j) {
case 0:
x = 0;
y = 0;
break;
case 1:
x = 3.0f / 4.0f * miniLongueur;
y = 5.0f / 2.0f * miniLongueur;
break;
case 2:
x = 13.0f / 4.0f * miniLongueur;
y = 5.0f / 2.0f * miniLongueur;
break;
case 3:
x = 4.0f * miniLongueur;
y = 0;
break;
case 4:
x = 2.0f * miniLongueur;
y = - 3.0f / 2.0f * miniLongueur;
break;
}
pushMatrix();
translate(x, y);
miniFleur13.display();
popMatrix();
// rotate(radians(72));
}
}
Thanks for your help.
1