2

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.

smark1
  • 21
  • 2

1 Answers1

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)

live demo for comparison

enter image description here

YellowAfterlife
  • 2,967
  • 1
  • 16
  • 24