Return actual coordinates after translate and rotate
in
Programming Questions
•
11 months ago
I'm sure this is simple trig but for some reason I just can't get it to work. The (a,b) offset keeps messing it up.
- translate(x,y);
- rotate(r);
- point(a,b);
How can I return the actual location of (a,b)?
This is correct as long as r = 0:
- return new PVector(x + cos(r) * a, y + sin(r) * b);
but that gets wonky depending on the value of r.
Thanks in advance!
EDIT:
Oddly, this seems to work right:
- return new PVector(x + cos(r) * b, y + sin(r) * b);
but that seems very strange to me, so I'd still love it if somebody could explain this to me.
1