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.
Asked
Active
Viewed 256 times
2

smark1
- 21
- 2
1 Answers
2
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)

YellowAfterlife
- 2,967
- 1
- 16
- 24