形状坐标逻辑 [英] Shape coordinates logic

查看:83
本文介绍了形状坐标逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个小圆形的传感器和一个大于传感器圆的孔。基本上我有一个小圆圈和一个大圆圈。现在我想检查这些条件:


(1)如果小圆圈在大圆的范围内,则结果应为0.


(2)如果小圆圈不在大圆圈范围内,则结果应为1.


(3)如果小圆圈部分被较大的圆圈阻挡或者从较大的圆圈内部或外部非常接近0.03,结果应该是X.


我不想写任何编码现在这只是一个简单的IF条件语句形式的逻辑陈述。


这是我到目前为止所做的。请随意纠正我的逻辑陈述


r1是大圆的半径,同样适用于x1,y1


r2是半径小圆圈同样适用于x2,y2

(1)IF(SQRT((X2-X1)^ 2 +(Y2-Y1)^ 2)< abs(R2- R1),那么价值是0


(2)IF(SQRT((X2-X1)^ 2 +(Y2-Y1)^ 2)> abs(R2-R1) ),那么价值是1


(3)(a)IF(SQRT((X2-X1)^ 2 +(Y2-Y1)^ 2)< = R1 + R2,(来自较大圆圈之外),那么值是X


(b)IF(SQRT((X2-X1)^ 2 +(Y2-Y1)^ 2) = abs(R2-R1),(从较大圆圈的内侧),那么值是X.


现在我唯一的问题是: -

当较大圆圈的边缘非常靠近较小圆圈30或触摸时,它应被视为X(换句话说,它不应超过0.03,否则它将是1或a 0取决于传感器是在孔内还是在外面。)有人可以帮帮我吗?先谢谢。

Hi,

I have a sensor in the shape of a small circle and a hole which is larger than the sensor circle. Basically i have a small circle and a large circle. Now i would like to check these conditions:

(1) IF the small circle is in the range of the large circle, then the result should be 0.

(2) IF the small circle is not in the range of the large circle, the result should be 1.

(3) IF the small circle is partially blocked by the larger circle or very close to it by 0.03 from inside or outside the larger circle, then the result should be X.

I don''t want to write any coding for this right now but a simple logic statements in the form of IF conditional statements.

This is what I have so far. Please feel free to correct my logic statements

r1 is radius of larger circle and same applies to x1,y1

r2 is the radius of smaller circle and same applies to x2,y2

(1) IF(SQRT((X2-X1)^2+(Y2-Y1)^2)< abs(R2-R1), THEN THE VALUE IS 0

(2) IF(SQRT((X2-X1)^2+(Y2-Y1)^2)> abs(R2-R1), THEN THE VALUE IS 1

(3) (a) IF(SQRT((X2-X1)^2+(Y2-Y1)^2)<= R1+R2, (from outside of the larger circle), THEN VALUE IS X

(b) IF(SQRT((X2-X1)^2+(Y2-Y1)^2)= abs(R2-R1), (from the inside of the larger circle), THEN VALUE IS X.

Now my only problem is this: -

When the edge of the larger circle is very close to the smaller circle by 30 thou or touching, it should be regarded as X (in other words, it should not exceed 0.03 or else it would be a 1 or a 0 depending on whether the sensor in inside the hole or outside of it). Can anybody please help me out? Thanks in advance.

推荐答案

这是对问题的非常好的总结。但是,我发现你最后有点不清楚,至于你需要帮助的部分。它是如何判断它们是否在0.03(什么单位?)或如何返回X而不是0/1,或者是什么?


另外,我是否正确我们' '应该假设圆圈是同心的? (也就是说,拥有相同的中心)


恐怕我没有详细说明你的逻辑(加上,几何不是我的强项)。但如果我正确阅读,abs(R2-R1)会给你两个圆圈之间的半径差异。所以,你不是只是要测试这个值是否大于0但小于0.03?
That was a very good summary of the problem. However, I found you were a little unclear at the end, as to precisely which part you need help with. Is it how to tell whether they are within 0.03 (what units?) or how to return X rather than 0/1, or what?

Also, am I correct in that we''re supposed to assume the circles are concentric? (That is, have the same centre)

I''m afraid I haven''t been over your logic in detail (plus, geometry is not my strong suit). But if I''m reading correctly, abs(R2-R1) gives you the difference in radius between the two circles. So aren''t you simply going to test whether this value is larger than 0 but smaller than 0.03?



这是一个非常好的问题摘要。但是,我发现你最后有点不清楚,至于你需要帮助的部分。它是如何判断它们是否在0.03(什么单位?)或如何返回X而不是0/1,或者是什么?


另外,我是否正确我们' '应该假设圆圈是同心的? (也就是说,拥有相同的中心)


恐怕我没有详细说明你的逻辑(加上,几何不是我的强项)。但如果我正确阅读,abs(R2-R1)会给你两个圆圈之间的半径差异。所以,你不是要简单地测试这个值是否大于0但小于0.03?
That was a very good summary of the problem. However, I found you were a little unclear at the end, as to precisely which part you need help with. Is it how to tell whether they are within 0.03 (what units?) or how to return X rather than 0/1, or what?

Also, am I correct in that we''re supposed to assume the circles are concentric? (That is, have the same centre)

I''m afraid I haven''t been over your logic in detail (plus, geometry is not my strong suit). But if I''m reading correctly, abs(R2-R1) gives you the difference in radius between the two circles. So aren''t you simply going to test whether this value is larger than 0 but smaller than 0.03?



我想要做的是提出两个条件语句,它们将检查两种情况并在非常接近边缘时产生结果X.


案例1:如果小圆圈在较大圆圈的范围内并且非常靠近大圆圈的边缘0.03,那么结果应该是X.我是什么mean是较小的圆边与较大的圆边之间的距离,范围应为0到0.03。到目前为止,我能够得出如下声明:IF(0 <= ABS(SQRT((X2-X1)^ 2 +(Y2-Y1)^ 2) - ABS(R2-R1))< = 0.01)然后返回X


情况2:如果小圆圈在较大圆圈之外且非常接近0.03(两条边缘之间的距离),则结果应为X.我还没有能够提出条件声明


圆圈不能同心,而且会有所不同。


我给出了两个圆圈的X和Y坐标,但是想检查以下条件。有任何想法吗?请随意纠正我的2个案例的逻辑。

What I want to do is to come up with two conditional statements that will check two cases and produce a result X if it is very close to the edges.

Case 1: If the small circle is in the range of the larger circle and is very close to the edge of the large circle by 0.03, then the result should be X. What I mean is the distance between the smaller circle edge and larger circle edge should range from 0 to 0.03. So far I was able to come up with a statement which is this: IF(0<=ABS(SQRT((X2-X1)^2+(Y2-Y1)^2) - ABS(R2-R1))<=0.01) THEN RETURN X

Case 2: If the small circle is outside of the larger circle and is very very close to 0.03 (distance between the 2 edges), the result should be X. I haven''t been able to come up with a conditional statement for that

The circles cannot be concentric and it varies.

I am given the X and Y coordinates of the two circles but would like to check the following conditions. Any ideas? Please feel free to correct my logic for the 2 cases.


啊!我想我现在明白了,对不起。


所以你要计算(A)每个圆的半径,以及(B)它们的中心点之间的距离。好了到目前为止?


所以我们假设您有值R1,R2和D.为方便起见,我会添加R1 + R2并调用结果AreaCovered(免费)组成一个更好的名字。


你实际上有三个条件要测试 - 接近边缘,重叠,不重叠。


很抱歉,但我觉得这种逻辑比pseduo-code更容易用编程语言编写。无论如何,这听起来怎么样......
Ah! I think I get it now, sorry.

So you''re calculating (A) the radius of each circle, and (B) the distance between their centre points. OK so far?

So let''s assume you have values R1, R2 and D. For convenience, I''ll add R1 + R2 and call the result AreaCovered (feel free to make up a better name).

You actually have three conditions to test - close to the edge, overlapping, and not overlapping.

Sorry, but I find this sort of logic easier to write in a programming language than "pseduo-code". Anyway, how does this sound...
展开 | 选择 | Wrap | 行号


这篇关于形状坐标逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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