Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我想将笛卡尔系统中给出的一些点坐标转换为对数极坐标笛卡尔系统。
但是,我不确定如何很好地执行atan操作。 目前,我正在按照以下步骤进行操作,这看起来非常丑陋。 Xlp = zeros(n, 2); Xlp(:, 1) = log(sqrt(Xt(:, 1).^2 + Xt(:, 2).^2)); sel = Xlp(:, 1) >= 0 && Xlp(:, 2) >= 0; Xlp(sel, 2) = atan(Xt(sel, 2) / Xt(sel, 1)); sel = Xlp(:, 1) >= 0 && Xlp(:, 2) < 0; Xlp(sel, 2) = repmat(2*pi, size(sel), 1) + atan(Xt(sel, 2) / Xt(sel, 1)); sel = Xlp(:, 1) < 0 && Xlp(:, 2) >= 0; Xlp(sel, 2) = repmat(pi, size(sel), 1) + atan(Xt(sel, 2) / Xt(sel, 1)); sel = Xlp(:, 1) < 0 && Xlp(:, 2) < 0; Xlp(sel, 2) = repmat(pi, size(sel), 1) + atan(Xt(sel, 2) / Xt(sel, 1)); 输入点在Xt中,第一列为X坐标值,第二列为Y坐标值。 Xlp包含对数极坐标,作为对应于距离的第一列和对应于角度的第二列给出。 回答: 使用atan2()为您完成所有这些艰苦的工作。 更多&回答... |
![]() |
![]() |