[英]Given many circles and a point, how to find which circle contains that point
[英]How to find out how much of the circumference of a given circle is covered by other intersecting circles?
我有一个带有中心坐标和半径的圆。
平面中还存在其他具有已知位置和相同半径的圆。
如何用Matlab找出给定圆的圆周的一部分,该圆周被平面中的其他圆覆盖?
通用方法是:
以及如何计算您的圆和另一个圆所覆盖的圆周部分?
您可能会更早返回,结果是整个圆周都被覆盖了,但是如果没有覆盖,您将不得不测试其他每个圆。
仅因为所有圆的半径相等,才有效。 如果其他圆圈较小,也可以,但如果较大,则不会总是得到交点,这会使整个问题变得更加困难。 但是您说过,这里不是这样。
正如Trilarion解释的那样,在计算的核心,您需要将两个圆相交。 您可以在网上找到与此相关的代码,也可以编写自己的代码。 一种来源是C语言中的“计算几何” ,它是与2D机器人手臂运动( arm.c
)相关的代码,其中包括使两个圆相交的功能。 有些退化的情况必须谨慎处理:两个圆仅相交一个点,或者相等的圆相交一个完整的圆。
从角度来看,您可以使用matlab pde向我们展示数据
pdecirc(1,2,3)
pdecirc(-1,-1,2)
如果要使用方程式将其绘制在matlab上,则为:
n = 100 % Resolution
angle = 0:2*pi/n:2*pi; % vector of angles at which points are drawn
angle = 0:2*pi/n:2*pi; % vector of angles at which points are drawn
R = 3; % radius
R = 3; % radius
x = R*cos(angle)+2; y = R*sin(angle)+1; % Coordinates of the circle
x = R*cos(angle)+2; y = R*sin(angle)+1; % Coordinates of the circle
plot(x,y); % Plot the circle
x = R*cos(angle)+2; y = R*sin(angle)+1; % Coordinates of the circle
plot(x,y); % Plot the circle
plot(x,y); % Plot the circle
axis equal;
grid on;
并且您可以根据需要绘制任意数量的图,如果需要非常高的分辨率,则可能必须将n设置为高值。 现在开始您的问题..使用matlab circcirc查找您的圆的相交点,有关更多详细信息,请参见http://uk.mathworks.com/help/map/ref/circcirc.html
[xout,yout] = circcirc(1,2,3,-1,-1,2); %which returns the x-intersects and the y-intersects
您可以将x和y相交分组,并根据半径和相交来计算周长。 如果您不知道如何操作,请检查此http://mathcentral.uregina.ca/QQ/database/QQ.09.07/h/michelle3.html假设您有两个以(1,2)和(-1为中心的圆圈, -1)
i = pdist([xout(1),yout(1);xout(2),yout(2)],'euclidean') %distance between intersects
P = [xout(1),yout(1);1,2] %coordinate of one of the intersections and your centre
E = pdist(P,'euclidean')
y = asin(i/(2*E))*2 %angle of your arc
cir = pi*2*R1*(y/(2*pi))
圆弧的比率乘以总周长
除非我高中的数学使我失望,否则这应该可以在2个圆圈之间给您答案。
PS:使用circcirc的好处是,如果圆不相交(即重叠或不相互接触,它将返回NaNs作为您的坐标,然后您可以对其进行处理)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.