Using atan2 to rotate XY
in
Programming Questions
•
10 months ago
Hi, I've allready searched the forum, but I couldn't figure it out. I have an array of vectors and I want to rotate them all. I've made a class with the following:
- float angle() {
- float xVT = (vecDist.vector[1].x-vecDist.vector[0].x) ;
- float yVT = (vecDist.vector[1].y-vecDist.vector[0].y);
- float angle = atan2( xVT, yVT);
- return angle;
- }
- rotate(polybuilding.angle());
- noFill();
- stroke(255);
- pushMatrix();
- translate(-polybuilding.width()/2, -polybuilding.height()/2);
- polybuilding.draw();
- for ( int z=0; z< tempVector.length; z++) {
- float xV = (tempVector[z].x-vecDist.vector[0].x)+angle();
- float yV = (tempVector[z].y-vecDist.vector[0].y)+angle() ;
- ellipseMode(CENTER);
- ellipse(xV, yV, 2, 2);
- noFill();
- stroke(255);
- vertex(xV, yV);
- }
1