angle between 2 PVectors
in
Programming Questions
•
1 year ago
To begin i want to draw a line in the direction of pos1, pos2.
Atm it's rotated to much, and i don't understand why cause the code looks so logic.
- PVector pos1, pos2, pos3, pos4;
- void setup() {
- size(400, 400);
- pos1 = new PVector(50, 50);
- pos2 = new PVector(width-50, 100);
- pos3 = new PVector(width-50, 200);
- pos4 = new PVector(50, 300);
- }
- void draw() {
- quad(pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, pos4.x, pos4.y);
- float a1 = PVector.angleBetween(pos1, pos2);
- translate(pos1.x - 10, pos1.y - 10);
- rotate(a1);
- line(0, 0, 100, 0);
- }
1