Intuitive angle plotting

I am trying to build an object title. I have four point vectors - let's call them

  • mdex
  • mdey(aka x1,y1),
  • thpx
  • thpy(aka x2,y2).

I find the change in y, and change in x( dyand dx), and then inserting it into a function atan2d. Then I look at the results and draw them on the chart.

The scale on the chart goes from -180 to 180. My problem occurs when the line goes through -180 or 180 degrees. Then it β€œpops up” to the opposite side of the chart (i.e. What would be 181 is actually -179).

This is problematic because it looks like there are big shifts in the corner, when in fact it is not - it is just a β€œflipping”. Also, it twists my angular speed calculations, which are based on how much has changed between points. Initially, I just tried to convert the chart to a 0-360 scale, adding 180 to all the values ​​that were below 0. That didn't work.

Here is a graph so you can better understand the problem (a graph after I tried the 0-360 conversion).

blah

My question

I am wondering if there is another function that I can use to calculate an angle that would give me a value that is constantly increasing, a way to modify the data so that it draws nicely, or a way to change the graph so that it looks intuitive?

Thanks in advance!

+4
1

unwrap, . :

>> ang = [150 160 170 180 -170 -160] %// undesired jump from 180 to -180
ang =
   150   160   170   180  -170  -160

>> 180/pi * unwrap(ang * pi/180)
ans =
   150   160   170   180   190   200
+7

Source: https://habr.com/ru/post/1548653/


All Articles