【问题标题】:C# convert magnitude/phase to real/imaginaryC# 将幅度/相位转换为实数/虚数
【发布时间】:2011-03-08 00:54:41
【问题描述】:

如果给定傅里叶变换的极坐标,我想返回笛卡尔(实/虚)坐标,我该怎么做?

我可以使用以下代码从笛卡尔坐标中获取极坐标数:

    private double GetPhase(double real, double imaginary)
    {
         return Math.Atan2(imaginary, real);
    }

    private double GetMagnitude(double real, double imaginary)
    {
        return Math.Sqrt((real * real) + (imaginary * imaginary));
    }

但是我怎么回去呢?

【问题讨论】:

  • 这真的是一道数学题,与编程无关。

标签: c# math


【解决方案1】:

不就是这样吗:

(伪代码)

x = cos(angle) * magnitude
y = sin(angle) * magnitude

(如果您使用计算机的倒置坐标系,请使用负罪) ?

【讨论】:

  • 我相信这是正确的! 6 分钟后我会接受你的回答 :) 我知道这很简单!
【解决方案2】:

添加到@BlueMonkMN 的答案:

private  double GetX (double angle, double magnitude)
{
    return Math.Cos(angle) * magnitude;
}

private  double GetY (double angle, double magnitude)
{
    return Math.Sin(angle) * magnitude;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-17
    • 2015-11-28
    • 2020-04-09
    • 1970-01-01
    相关资源
    最近更新 更多