11505 - Logo
Solution Description : This problem can be done easily with vector decomposition. Keep three variables, x, y, and theta, all initially 0. At every step: rt q: theta -= q lt q: theta += q fd q: x += q*cos(theta), y += q*sin(theta) bk q: x -= q*cos(theta), y -= q*sin(theta) You may need to convert theta to radians depending on the library you use, so multiply by (theta*pi)/180. use pi = 2*acos(0.0) I made sure that my theta stayed between 0 and 360 the whole time, in/decrementing as necessary, but you probably don't have to. It's just that no bounds are given on theta. |
||||||||||