I tried to solve this using multiple methods but i couldn't figure it out. i don't know what to use in order to solve this basically i have an input x and x2
Heading
when x = 1 and x2 = 1 Y = 45
when x = 1 and x2 = -1 Y = 315
when x = -1 and x2 = 1 Y = 135
when x = -1 and x2 = -1 Y = 225
when x = 0 and x2 = 1 Y = 90
when x = 0 and x2 = -1 Y = 270
when x = 1 and x2 = 0 Y = 360
when x = -1 and x2 = 0 Y = 180
To explain it more i want an equation that when ever i input x ,x2 values in it i get the same y value. Ii don't know if its feasible or if math can deal with that type of situation but i believe that somehow there should be a way to make that equation I tried to use Excel to solve this as a regression but it didn't work
First of all, if you are asking how to find an angle given 2 coordinates, in vast majority of languages, there is a function
atan2(y,x)(or with similar name) that allows you to pass coordinates and get the value of the angle: $$ Y=\frac{180}{\pi}\mathop{\mathrm{atan2}}(x_2,x_1). $$ If we insist we want integer number from $1$ to $360$, we can add modulus shift: $$ Y = \mathrm{rem}\left(\left[\frac{180}{\pi}\mathop{\mathrm{atan2}}(x_2,x_1)-1\right], 360\right)+1. $$ In C it would be translated as((int)round(180/PI*atan2(x2,x1)-1) % 360)+1If we do not want trigonometric function for suchsimple problem and also do not want to use precalculated array, we can go like this. You can represent your data in a table $A_{ij}$, where $i,j=-1,0,1$: $$ A=45 \left( \begin{array}{ccc} 5 & 4 & 3 \\ 6 & \cdot & 2 \\ 7 & 8 & 1 \\ \end{array} \right) $$
All numbers except 8 can be represented as a bilinear interpolation of the corners: $$ Y'=4-2x_2-x_1x_2,\qquad A'=\left( \begin{array}{ccc} 5 & 4 & 3 \\ 6 & \cdot & 2 \\ 7 & 4 & 1 \\ \end{array} \right) $$
Now we need to add 4 to the bottom 4 to get 8. We can do it with the trick $2 (x_1+1) \left(1-x_2^2\right)$. Finally: $$ Y=45\left(4-2x_2-x_1x_2+2 (x_1+1) \left(1-x_2^2\right)\right) $$