[Matlab six-degree-of-freedom robot] Understanding of the double-variable function atan2
recent update
【Main line】
- Build a robot model
- Correct solution of kinematics
- Construction of workspace based on Monte Carlo Method
【Supplementary explanation】
- Understanding of Flexible Workspaces and Accessible Workspaces
- Detailed establishment steps of modified DH parameters (modified Denavit-Hartenberg)
- Questions about parameterization of rotation (Euler angles, attitude angles, quaternions)
text
About the atan2() function
Using the bivariate function A tan 2 ( y , x ) Atan2(y,x)A t a n 2 ( y ,x)计算 a r c t a n ( y / x ) arc tan(y/x) The advantage of a r c t a n ( y / x ) is that it uses the signs of x and y, so it candetermine the quadrant of the resulting angle。
For example:
A tan 2 ( − 2.0 , − 2.0 ) = − 135 ° Atan2(-2.0,-2.0)=-135°A t a n 2 ( − 2 . 0 ,−2.0)=−135°
rad2deg(atan2(-2.0,-2.0))
A t a n 2 ( 2.0 , 2.0 ) = 45 ° Atan2(2.0,2.0) = 45° A t a n 2 ( 2 . 0 ,2.0)=45°
rad2deg(atan2(2.0,2.0))
However , the two angles cannot be distinguished using the univariate arctangent function
For example:
A tan ( 2.0 / 2.0 ) = 45 ° Atan(2.0/2.0) = 45°A t a n ( 2 . 0 / 2 . 0 )=45°
rad2deg(atan(2.0/2.0))
Then A tan ( − 2.0 / − 2.0 ) = 45 ° Atan(-2.0/-2.0) = 45 °A t a n ( − 2 . 0 /−2.0)=45°
rad2deg(atan(-2.0/-2.0))```
Since the range we set when calculating the angle is usually 360° 360°3 6 0 ° , so the Atan2() function is used. The advantage of the two-variable arctangent function is also known as the "4-quadrant arctangent" function, which is specified in some libraries, such asmatlab. Finally, it is stipulated that when both variables are zero,A tan 2 ( 0 , 0 ) = 0 Atan2(0,0)=0A t a n 2 ( 0 ,0)=0