[Matlab six-degree-of-freedom robot] Explanation of the double-variable function atan2(x,y)

[Matlab six-degree-of-freedom robot] Understanding of the double-variable function atan2

recent update

【Main line】

  1. Build a robot model
  2. Correct solution of kinematics
  3. Construction of workspace based on Monte Carlo Method

【Supplementary explanation】

  1. Understanding of Flexible Workspaces and Accessible Workspaces
  2. Detailed establishment steps of modified DH parameters (modified Denavit-Hartenberg)
  3. 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))

insert image description here
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))

insert image description here

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))

insert image description here
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))```

insert image description here
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

Guess you like

Origin blog.csdn.net/AlbertDS/article/details/110236650