【问题标题】:Create a spiral between two cartesian points in MATLAB在 MATLAB 中创建两个笛卡尔点之间的螺旋
【发布时间】:2016-07-25 18:58:42
【问题描述】:

也许这是一个基本问题,但我还没有找到类似的东西,我想知道如何以最好的方式做到这一点。

我有两组点 (x1,y1,z1) 和 (x2,y2,z2),我已将它们转换为极坐标。我想创建一个半径减小的逆时针螺旋线以到达第二个点。

我还想指定它需要多少转。

我看到的所有例子都是x轴上的两个点,顺时针方向。

非常感谢任何建议!

谢谢。

【问题讨论】:

标签: matlab plot cartesian spiral helix


【解决方案1】:

此示例代码生成一个从 p1 到 p2 的逆时针螺旋线,它不在 x 轴上,您可以指定转数。然而,它是二维的,初始点是笛卡尔坐标。我不确定如何在 3D 中执行此操作,但我希望这可以帮助您解决偏移和逆时针方向。

%random 2d points
p1 = [3,5];
p2 = [1,4];

%radius of first point to second
r = norm(p1-p2);
%angle between two point wrt the y-axis
theta_offset = tan((p1(2)- p2(2))/(p1(1)-p2(1)));

rez = 150; % number of points 
rev = 5; % number of revolutions

t = linspace(0,r,rez); %radius as spiral decreases
theta = linspace(0,2*pi*rev,rez) + theta_offset; %angle as spiral decreases
x = cos(theta).*t+p2(1); 
y = sin(theta).*t+p2(2);
plot(x,y)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-27
    • 2020-05-08
    • 2012-11-03
    • 2012-04-07
    • 2012-09-26
    • 2013-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多