Reputation: 21
I wonder how lenghtdir_x/y
is implemented. To my understanding this has something to do with trigonometry but since I'm a fairly new to all of this I can't figure it out myself.
Upvotes: 2
Views: 396
Reputation: 3202
You are correct, it is a bit of trigonometry - namely, converting from degrees to radians, and then multiplying a sine/cosine of that angle by "length" (hence why it is called length-dir)
lengthdir_x(l, d)
is l * cos(d * pi / -180)
lengthdir_y(l, d)
is l * sin(d * pi / -180)
Upvotes: 2