两个弧之间的交集? (弧=一对角度之间的距离) [英] Intersection between two Arcs? (arc = distance between pair of angles)

查看:220
本文介绍了两个弧之间的交集? (弧=一对角度之间的距离)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法来计算两个弧之间的交点。
我需要使用它来确定圆弧的右半部分有多少弧线,左边有多少。
我虽然关于创建右半部分的弧线,并将其与实际弧线相交。
但是需要我花很多时间来解决这个问题,所以我想在这里问 - 有人必须先完成它。



编辑:
对不起,前面的插图是在嘎吱嘎吱的角度后头部太重时提供的。我会再试解释一下:



此链接,您可以看到我将中间的圆弧切成两半,圆弧的右侧部分包含135度,左侧部分包含90度。



这个弧开始于-180,结束于45.(或开始于180,结束于405如果规范化)。



我已经设法创建此代码为了计算在右边部分和左边部分中包含的弧度的数量:

  f1 =(angle2> 270.0f≤270.0f:angle2) - (angle1 <90.0f≤90.0f:angle1); 
if(f1 <0.0f)f1 = 0.0f;
f2 =(angle2> 640.0f?640.0f:angle2) - (angle1 <450.0f?450.0f:angle1);如果(f2 <0.0f)f2 = 0.0f,则
;
f3 =(angle2> 90.0f?90.0f:angle2) - angle1;如果(f3 <0.0f)f3 = 0.0f,则
;
f4 =(angle2> 450.0f?450.0f:angle2) - (angle1 <270.0f?270.0f:angle1);如果(f4 <0.0f)f4 = 0.0f,则
;

在将角度归一化为非负值后,它的效果很好,但是从360开始。
然后f1 + f2给我左半部分的总和,f3 + f4给我右半部分的总和。
当arc被定义为超过360时,它也不会考虑这种情况,这可能是一个错误情况。



但是,这看起来像更多的是解决方法,而不是一个正确的数学解决方案。
我正在寻找一个更优雅的解决方案,它应该基于两个弧之间的交集(因为数学没有边,它不是可视化的);

感谢!!

解决方案

我认为这有效,但我没有彻底测试过。每个弧线都有一个起始角度和一个终止角度,我将按照你所做的顺时针方向测量它的顺时针角度,但从数学家的角度来看,从东方逆时针方向测量的弧度也是一样容易的。 。

首先标准化你的弧线,也就是说,减少它们中的所有角度,使它们位于 [0,360),所以取出360deg的倍数,并使所有角度+ ve。确保每个弧的停止角在于开始角的顺时针。



接下来,选择其中一个圆弧的起始角度,将其中的所有角度(其中4个)按数字顺序排序,如果任何角度的数字为s小于您选择的起始角度,请向它们添加360deg。



将角度重新排序以增加数字顺序。您选择的起始角度将成为新列表中的第一个元素。从你已经选择的开始角度,列表中的下一个角度是多少?



1)如果是相同弧的停止角,那么要么没有重叠或者这个弧线完全包含在另一个弧线内。记下音符并找到下一个角度。如果下一个角度是另一个弧的起始角度,则没有重叠,您可以停止;如果它是另一个弧的停止角,则重叠包含整个第一弧。停止

<2>如果它是另一个弧的起始角度,则重叠开始于该角度。记下这个角度。扫描遇到的下一个角度必须是停止角度,重叠结束于此。停止。


3)如果它是另一个弧的停止角,那么重叠包括第一个弧的起始角与该角之间的角度。停止。

这不是特别优雅,依赖于ifs,而不是我通常喜欢的,但它应该可以工作,并且相对容易翻译成您最喜欢的编程语言。



再看看,根本没有三角关系!

编辑



这是一个更数学的方法,因为你似乎觉得需要。



对于( - pi,pi)双曲正弦函数(通常称为 sinh )将角度映射到间隔中实线上的间隔(大约)( - 11.5,11.5)。与 arcsin arccos
<1>如果一个弧包含0将其分成2个弧,那么这个函数的反函数也是在同一个区间内是单值的。 (start,0)(0,stop)。现在您有2,3或4个区间线。


2)计算这些间隔的交点并从线性测量值转换回角度测量值。你现在有两个弧的交点。


I'm trying to find a way to calculate the intersection between two arcs. I need to use this to determine how much of an Arc is visually on the right half of a circle, and how much on the left. I though about creating an arc of the right half, and intersect that with the actual arc. But it takes me wayyy to much time to solve this, so I thought about asking here - someone must have done it before.

Edit: I'm sorry the previous illustration was provided when my head was too heavy after crunching angles. I'll try to explain again:

In this link you can see that I cut the arc in the middle to two halves, the right part of the Arc contains 135 degrees, and the left part has 90.

This Arc starts at -180 and ends at 45. (or starts at 180 and ends at 405 if normalized).

I have managed to create this code in order to calculate the amount of arc degrees contained in the right part, and in the left part:

f1 = (angle2>270.0f?270.0f:angle2) - (angle1<90.0f?90.0f:angle1);
if (f1 < 0.0f) f1 = 0.0f;
f2 = (angle2>640.0f?640.0f:angle2) - (angle1<450.0f?450.0f:angle1);
if (f2 < 0.0f) f2 = 0.0f;
f3 = (angle2>90.0f?90.0f:angle2) - angle1;
if (f3<0.0f) f3=0.0f;
f4 = (angle2>450.0f?450.0f:angle2) - (angle1<270.0f?270.0f:angle1); 
if (f4<0.0f) f4=0.0f;

It works great after normalizing the angles to be non-negative, but starting below 360 of course. Then f1 + f2 gives me the sum of the left half, and f3 + f4 gives me the sum of the right half. It also does not consider a case when the arc is defined as more than 360, which may be an "error" case.

BUT, this seems like more of a "workaround", and not a correct mathematical solution. I'm looking for a more elegant solution, which should be based on "intersection" between two arc (because math has no "sides", its not visual";

Thanks!!

解决方案

I think this works, but I haven't tested it thoroughly. You have 2 arcs and each arc has a start angle and a stop angle. I'll work this in degrees measured clockwise from north, as you have done, but it will be just as easy to work in radians measured anti-clockwise from east as the mathematicians do.

First 'normalise' your arcs, that is, reduce all the angles in them to lie in [0,360), so take out multiples of 360deg and make all the angles +ve. Make sure that the stop angle of each arc lies to clockwise of the start angle.

Next, choose the start angle of one of your arcs, it doesn't matter which. Sort all the angles you have (4 of them) into numerical order. If any of the angles are numerically smaller than the start angle you have chosen, add 360deg to them.

Re-sort the angles into increasing numerical order. Your chosen start angle will be the first element in the new list. From the start angle you already chose, what is the next angle in the list ?

1) If it is the stop angle of the same arc then either there is no overlap or this arc is entirely contained within the other arc. Make a note and find the next angle. If the next angle is the start angle of the other arc there is no overlap and you can stop; if it is the stop angle of the other arc then the overlap contains the whole of the first arc. Stop

2) If it is the start angle of the other arc, then the overlap begins at that angle. Make a note of this angle. The next angle your sweep encounters has to be a stop angle and the overlap ends there. Stop.

3) If it is the stop angle of the other arc then the overlap comprises the angle between the start angle of the first arc and this angle. Stop.

This isn't particularly elegant and relies on ifs rather more than I generally like but it should work and be relatively easy to translate into your favourite programming language.

And look, no trigonometry at all !

EDIT

Here's a more 'mathematical' approach since you seem to feel the need.

For an angle theta in (-pi,pi] the hyperbolic sine function (often called sinh) maps the angle to an interval on the real line in the interval (approximately) (-11.5,11.5]. Unlike arcsin and arccos the inverse of this function is also single-valued on the same interval. Follow these steps:

1) If an arc includes 0 break it into 2 arcs, (start,0) and (0,stop). You now have 2, 3 or 4 intervals on the real line.

2) Compute the intersection of those intervals and transform back from linear measurement into angular measurement. You now have the intersection of the two arcs.

这篇关于两个弧之间的交集? (弧=一对角度之间的距离)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆