https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan
https://www.cuemath.com/trigonometry/arctan/
์ผ๊ฐ๋ฒ์์ arctan ์ ์ญ ํ์ ํธ ํจ์๋ฅผ ๋ํ๋ ๋๋ค. ์ญ์ผ๊ฐ ํจ์๋ ์ผ๋ฐ์ ์ผ๋ก ์ ๋์ฌ - arc๋ฅผ ๋๋ฐํฉ๋๋ค. ์ํ์ ์ผ๋ก ์ฐ๋ฆฌ๋ arctan ๋๋ ์ญํ์ ํธ ํจ์๋ฅผ tan -1 x ๋๋ arctan(x)๋ก ๋ํ๋ ๋๋ค.
์ํฌํ ๊ณต์
์์์ ๋ ผ์ํ ๋ฐ์ ๊ฐ์ด arctan์ ๊ธฐ๋ณธ ๊ณต์์ arctan(์์ง/๋ฐ๋ฉด) = θ๋ก ์ฃผ์ด์ง๋ฉฐ, ์ฌ๊ธฐ์ θ๋ ๋น๋ณ๊ณผ ์ง๊ฐ ์ผ๊ฐํ์ ๋ฐ๋ฉด ์ฌ์ด์ ๊ฐ๋์ ๋๋ค. ๊ฐ๋ θ์ ๊ฐ์ ๊ฐ๋ ๋๋ ๋ผ๋์์ผ๋ก ์ฐพ๊ธฐ ์ํด arctan์ ๋ํด ์ด ๊ณต์์ ์ฌ์ฉํฉ๋๋ค. ์ด ๊ณต์์ θ = tan -1 [Perpendicular / Base] ๋ก ์ธ ์๋ ์์ต๋๋ค .
const pos = this.startBtn.getGlobalPosition(); //{x: 535, y: 565}
const endPoint = this.goldUI.GlobalPosition(); //{x: 99, y: 174}
this.spine.x = pos.x;
this.spine.y = pos.y;
const rad = Math.atan((endPoint.x - pos.x) / (endPoint.y - pos.y));
this.spine.rotation = -rad;