Remapping Heading Angle to Coordinates to Move By
I'll separate this into two sections: readability and maintainability. I'm not exactly sure of the usage, so I don't feel I can comment on that.
Readability
Personally, I think the largest burden on the cleanliness of this code, is the comments. I think they're too large and there's too many.
One way to improve this, is PHPDocs. Just like JavaDocs, they help organize the functionality of code properties.
Another way to reduce them is to make your variables as meaningful as possible. What exactly is $deg? What kind of degree is it? Same principle for $xdeg and $x.
Breaking apart one large method into several smaller functions can also improve the cleanliness, not to mention the benefits of modularized code and improved organization.
One last note: I see a lot of numbers. What's the decision behind these numbers. Making some of the numbers in map(180,360,180,0 constants or variables at the top can help readers understand the meaning.
Maintainability
You code is very simple (as in it takes care of one thing), and I think this is the greatest tool to avoiding confusion in the future.
Having well documented code is also great, just make sure your wording is clear and concise. Sometimes referencing to other code in the comments can help. Explain why, not how.
I don't think there's too much else you can do to future-proof this!