在圆上绘制角度线并获取相交点 [英] Draw angles lines over circle and get the intersecting points
问题描述
我希望在圆上绘制角度线(我在脚本中更改角度).我得到的绘图线是0角,为什么脚本没有向我显示所有角度,我该如何解决? 另外,如何计算相交点?
I wish to draw angle lines over a circle (I change the angles in the script). The plot line I get is 0 angle, why does the script not show me all of them, and how can I fix it? In addition, how can I calculate the intersection points?
脚本:
clc;
clear;
close all;
r=1000;
% based on : https://stackoverflow.com/questions/29194004/how-to-plot-a-circle-in-matlab
nCircle = 1000;
t = linspace(0,2*pi,nCircle);
xCircle = 0+ r*sin(t);
yCircle = 0+ r*cos(t);
line(xCircle,yCircle );
axis equal;
hold on;
nAngles = 45;
inceasedNumber = 360/nAngles;
lineLength = r+50;
for angle = 0:359:inceasedNumber
xLine(1) = 0;
yLine(1) = 0;
xLine(2) = xLine(1) + lineLength * cosd(angle);
yLine(2) = yLine(1) + lineLength * sind(angle);
plot(xLine, yLine);
end
推荐答案
我认为您的for
循环的定义有误.步长必须出现在迭代的开始和结束之间的中间位置:
I think there is a mistake in the definition of your for
loop. The stepsize must appear in the middle between start and end of the iteration:
for angle = 0:inceasedNumber:359
此外,MATLAB使用弧度指定角度,因此360°等于2pi,您必须相应地更改输入.
Furthermore MATLAB is using Radians to specify an angle, hence 360° equals 2pi and you have to change your inputs accordingly.
对于直线和圆的交点,在实现之前我会考虑几何形状;)
For the intersection of the lines and the circle I would consider geometry before implementation ;)
这篇关于在圆上绘制角度线并获取相交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!