get corner coordinates of a rectangle
in
Programming Questions
•
2 years ago
How can i get the corner coordinates of a rotated rectangle where i know the center point, the width and height and the rotation.
I want to avoid using screenX and screenY, for presicion and learning.
I want to avoid using screenX and screenY, for presicion and learning.
- Something something = new Something(300, 300, radians(45));
void setup(){
size(600, 600);
something.display();
// how do i get the corner coordinates?
}
class Something{
int x;
int y;
float rotation;
float Width = 100;
float Height = 400;
Something(int x, int y, float rotation){
this.x = x;
this.y = y;
this.rotation = rotation;
}
void display(){
pushMatrix();
translate(x, y);
rotate(rotation);
rectMode(CENTER);
fill(0, 60);
rect(0, 0, Width, Height);
fill(0);
rect(0, 0, Width, 1);
popMatrix();
}
}
1