## Understanding maths behind axis values / how to calculate axis values by given angles?

General Chat, Feel Free To talk about anything here.
cataz
Posts: 14
Joined: Thu Dec 05, 2019 12:04 pm

### Understanding maths behind axis values / how to calculate axis values by given angles?

Hi guys I hope you are all healthy and well. Im working on my project and need help understanding how the axis values are calculated for a given motion, like when we move our thumb into a certain angle.

To give an actual use case / illustrate what I want to calculate I made a picture with two arrows: How would you calculate the correct X and Y values for a given angle?
Like in the example arrow 1) which X-Y vlaues would represent a 60° thumb motion?
Or 2) which X-Y axis values would represent a 140° thumb motion?
cataz
Posts: 14
Joined: Thu Dec 05, 2019 12:04 pm

### Re: Understanding maths behind axis values / how to calculate axis values by given angles?

I wrote a simple program which shows current X and Y values of my controllers left stick and the angle the current current motion is representing. I noticed somewhere around 60° the X value starts to decrease until by 0° it is 0. Between like 58° and like 121° the X value is maxed. Here are some example outputs:

Max Values are between -127.996094 and 127.996094

60° motion:

Code: Select all

``````LX: 127.996094
LY: -73.789063
L motion: 60.04``````
90° motion:

Code: Select all

``````LX: 127.996094
LY: 0.500000
L motion: 90.22``````
140° motion:

Code: Select all

``````LX: 88.843750
LY: 107.917969
L motion: 140.54``````
Above I read actual controller X and Y values of my controller and calculated the Angle. What I want is the other way around. I want to calculate X and Y values for a given angle.

By looking at the values above I couldn't figure out the maths. I would love any input from you guys. Stay healthy and cheers!
Matlo
Posts: 5709
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

### Re: Understanding maths behind axis values / how to calculate axis values by given angles?

The maths branch you are looking for is called trigonometry: https://en.wikipedia.org/wiki/Trigonometry
Have a look at the sine and cosine functions.
GIMX creator
Matlo
Posts: 5709
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

### Re: Understanding maths behind axis values / how to calculate axis values by given angles?

Topic moved to discussion section.
GIMX creator
cataz
Posts: 14
Joined: Thu Dec 05, 2019 12:04 pm

### Re: Understanding maths behind axis values / how to calculate axis values by given angles?

I've looked into sine and cosine functions and tried to calculate the controller X and Y values for a given angle / motion.

Example calculation:
* angle / motion: 140
* max axis values: 128
* LX = 128 * cos(2.44) = -97.768345866
* LY = 128 * sin(2.44) = 82.6156797868

Unfortunately I seem to miss something since actual controller inputs in gimx show different x-y values than my calculation.