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

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

问题描述

我正在尝试找到一种方法来计算两条弧之间的交点.我需要用它来确定圆的右半部分在视觉上有多少弧,在左半部分有多少.我想创建一个右半边的弧,并将其与实际弧相交.但是我花了很多时间来解决这个问题,所以我想在这里问 - 以前肯定有人做过.

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.

很抱歉之前的插图是在我的头在咬合角度后太重时提供的.我再解释一遍:

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

这个链接中你可以看到我把中间的弧线切成两段对半,圆弧的右侧部分为 135 度,左侧部分为 90.

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.

此弧从 -180 开始,到 45 结束.(如果标准化,则从 180 开始,到 405 结束).

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;

将角度归一化为非负后效果很好,但当然从 360 度以下开始.然后 f1 + f2 给我左半部分的总和,f3 + f4 给我右半部分的总和.也没有考虑弧度超过360的情况,可能是错误"的情况.

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";

谢谢!!

推荐答案

我认为这有效,但我还没有对其进行彻底的测试.您有 2 条弧线,每条弧线都有一个起始角和一个停止角.我会像你所做的那样,以从北顺时针测量的度数来计算这个,但是从东面逆时针测量的弧度和数学家一样容易计算.

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.

首先标准化"你的弧线,也就是说,将它们中的所有角度都减小到 [0,360) 之内,所以取出 360deg 的倍数并使所有的角度为 +ve.确保每个圆弧的停止角都在起始角的顺时针方向.

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.

接下来,选择其中一个弧的起始角度,哪个都无关紧要.将您拥有的所有角度(其中 4 个)按数字顺序排序.如果任何角度在数值上小于您选择的起始角度,请将它们加上 360 度.

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) 如果它是同一弧的停止角,则要么没有重叠,要么该弧完全包含在另一弧内.记下并找到下一个角度.如果下一个角度是另一个圆弧的起始角度,则没有重叠,您可以停止;如果它是另一条弧的停止角,则重叠包含整个第一条弧.停止

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) 如果是另一条弧的起始角,则重叠从该角开始.记下这个角度.您扫掠遇到的下一个角度必须是一个停止角,并且重叠在那里结束.停止.

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) 如果它是另一条弧的终止角,则重叠包括第一条弧的起始角与该角之间的角度.停止.

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.

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

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 !

编辑

这是一种更数学"的方法,因为您似乎觉得有必要.

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

对于 (-pi,pi] 中的角度 theta,双曲正弦函数(通常称为 sinh)将角度映射到区间实线上的区间(大约)(-11.5,11.5].与arcsinarccos 不同的是,这个函数的反函数也是相同区间上的单值.请按照以下步骤操作:

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) 如果一个弧包含 0,则将它分成 2 个弧,(start,0)(0,stop).您现在在实线上有 2、3 或 4 个区间.

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) 计算这些间隔的交集并将线性测量转换回角度测量.您现在有两条弧线的交点.

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天全站免登陆