【问题标题】:Plot from Cartesian to polar从笛卡尔到极坐标
【发布时间】:2015-11-08 22:45:32
【问题描述】:

我正在使用左声道和右声道来创建 Lissajous Vectorscope。 Left 是 x,Right 是 y,两者都不会超过 1 和 -1 值。这些坐标也以 45 度角移动,以提供以下视图。

所以我在做一个很简单的

// converting x and y value from (-1 - 1) to (0 - 1)
float x = LeftChannelValue/2 + 0.5
float y = RightChannelValue/2 + 0.5

// multiplying the width and height with X and Y to get a proper square
// width and height have to be the same value 
float new_X = x*(width*0.5)
float new_Y = y*(height*0.5)

// doing two dimensional rotating to 45 degrees so it's easier to read
float cosVal = cos(0.25*pi)
float sinVal = sin(0.25*pi)

float finalX = (((new_X*cosVal)-(new_Y *sinVal))) + (width*0.5) //adding to translate back to origin 
float finalY = ((new_X*sinVal) + (new_Y *cosVal)) 

这给了我那张照片的结果。

如何绘制极坐标图,使其看起来不像正方形,而更像圆形? 我试图得到这个观点,但我对这与左右的关系感到非常困惑。我使用https://en.wikipedia.org/wiki/Polar_coordinate_system 作为参考。

【问题讨论】:

  • 李萨如图不涉及笛卡尔/极坐标变换 - 您的目标是什么?
  • 我已经有一个笛卡尔的利萨如图。我想将其转换为从 0 到 360 度的极坐标图。这就是我想要的。我想看起来像这样 help.izotope.com/docs/ozone/pages/images/… 但 360 度而不是 180 度
  • 找出问题所在,发布答案。谢谢!

标签: c++ polar-coordinates


【解决方案1】:

我明白了我想要什么。

我试图在极坐标图中绘制这些坐标。我做错了。

我最终意识到,为了转换 x,y 坐标,我需要自己定义半径和角度在我的 x,y 图表中应该代表什么。就我而言,我希望半径是 x 和 y 的最大绝对值

唯一的问题是试图弄清楚如何使用 x 和 y 值计算角度。

这就是我希望我的圈子工作的方式,

  1. x = y时,角度为0
  2. x = 1 & y = 0时,角度为45
  3. x = 1 & y = -1时,角度为90
  4. x = 0 & y = 1时,角度为-45
  5. x = -1 & y = 1时,角度为-90

根据这些信息,您可以计算出圆的其余坐标,最大 180- 180 度角。

我必须使用条件(if else 语句)来正确计算给定 x 和 y 的正确角度。

然后要绘制极坐标,您只需使用 cos 和 sin 转换为 x、y 坐标。

我喜欢编程,只是不擅长微积分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-17
    • 1970-01-01
    • 2012-04-13
    • 1970-01-01
    • 1970-01-01
    • 2013-08-05
    • 1970-01-01
    相关资源
    最近更新 更多