绘制一个直观的角度图 [英] Plotting an intuitive graph of angles

查看:248
本文介绍了绘制一个直观的角度图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图绘制一个对象的标题。我有四个向量点 - 让我们称它们为




  • mdex

  • mdey (aka x1,y1 ), thpx

  • thpy (aka x2 ,Y2 )。



我发现 y 中的变化以及 x dy dx ),然后输入 atan2d 函数。然后我浏览结果并将它们绘制在图表上。



图表上的比例从-180到180.当线经过-180或180度时,出现问题。然后弹出到图的另一侧(即,实际上181会是-179)。

这是有问题的,因为它看起来好像有很大的转角,但实际上并没有 - 这只是翻身。另外,这也会影响我的角速度计算,这是基于点之间有多少变化。最初,我试图通过将所有小于0的值加180来将图转换为0-360的比例。这是行不通的。



下面是图你可以更好地理解这个问题(图表是在我尝试0-360转换之后)。



我的问题



我想知道是否有另一个函数可以用来计算角度,值是不断增加的,一种修改数据的方式,使其能够很好地绘制,或者修改图形使其看起来直观?

预先感谢! 使用 .htmlrel =nofollow> unwrap 删除不需要的跳转。参数必须以弧度表示:

 >> ang = [150 160 170 180 -170 -160]%//不希望的从180跳到-180 
ang =
150 160 170 180 -170 -160

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


I'm trying to plot the heading of an object. I have four vectors of points - let's call them

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

I am finding the change in y and the change in x (dy and dx) and then entering that into the atan2d function. I then run through the results and plot them onto a chart.

The scale on the chart goes from -180 to 180. My problem arises when the line passes through -180 or 180 degrees. It then 'pops' to the opposite side of the graph (i.e. what would be 181 is actually -179).

This is problematic because it makes it look like there are massive shifts in angle when there really is not - it's just 'turning over'. Additionally, this screws up my angular velocity calculations, which are based on how much has changed between points. Originally, I just tried converting the graph to a 0-360 scale by adding 180 to all values that were below 0. This did not work.

Here's is the graph so you might understand the issue better (the graph is after I tried the 0-360 conversion).

My Question

I'm wondering if there's a different function I can use to calculate the angle that would give me a value that is ever increasing, a way to modify the data so that it plots nicely, or a way to modify the graph so it looks intuitive?

Thanks in advance!

解决方案

Use unwrap to remove the unwanted jumps. The argument must be in radians:

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

这篇关于绘制一个直观的角度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆