【发布时间】:2017-08-11 06:20:02
【问题描述】:
我想要一个圆上的 N 个点,由 50 的欧几里得距离(直线,而不是圆周)分开。半径由点的数量和连续点之间的距离决定。
但是,当我选择其中一个点作为参考并计算到其他点的距离时,我没有得到任何等于 50 的距离值。
下面是我的代码:
N = 100; % number of points
eclddst = 50; % euclidean distance between adjacent points
r = eclddst/(2*sin(pi/N)); % radius of the circle
cord = r*exp((0:1/(N-1):1)*pi*2*1i)'; % coordinates
XCor = real(cord);
YCor = imag(cord);
N_COORD = [XCor YCor];
% taking location 3 as the reference point to check the distance between the points
DSTNT = sqrt( (N_COORD(3,1)-N_COORD(:,1)).^2 + ( N_COORD(3,2)- N_COORD(:,2)).^2)';
我获得的第三点周围的距离值为:
100.959
50.505
0.000
50.505
100.959
151.311
与点 3 相邻的点的距离值应为 50,而不是 50.505。
为什么会出现此错误? 提前致谢。
【问题讨论】:
-
绳子的配方从何而来?你为什么要使用虚构的东西?另外,只是一个题外话:使用
linspace(0,1,N)而不是0:1/(N-1):1 -
@Tinacord的公式就是从这个link得到的。