問題は、真ん中にあるメイン PVector の周りに配置された PVector の配列を取得したことです。ローテーション変数に基づいて、PVector の配列をメインの PVector の周りで回転させたいと考えています。これを行う方法はありますか?
現在、私はこのコードを持っていますが、PVectors を回転させず、回転変数に基づいて遠くに配置するだけです。
class Box {
PVector location;
PVector[] points;
float rotation = random(360);
Box() {
location = new PVector(random(width), random(height));
points = new PVector[4];
for(a = 0; a < points.length; a ++) {
points[a] = new PVector(0,0);
}
}
void update() {
points[0].x = location.x + 10 * sin(rotation);
points[0].y = location.y + 10 * sin(rotation);
points[1].x = location.x + 10 * sin(rotation);
points[1].y = location.y - 10 * sin(rotation);
points[2].x = location.x - 10 * sin(rotation);
points[2].y = location.y + 10 * sin(rotation);
points[3].x = location.x - 10 * sin(rotation);
points[3].y = location.y - 10 * sin(rotation);
}