問題是我有一個PVectors陣列放置在我的主PVector這是在中間。我希望我的PVector陣列根據旋轉變量在我的主PVector周圍旋轉。有沒有辦法做到這一點?處理PVector旋轉
現在我有這個代碼,但它不旋轉PVectors,只是基於旋轉var將它們放在更遠的地方。
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);
}
你沒有考慮到一個點的帳戶原始座標。這是故意的嗎? – Basilevs