Shape coordinates logic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nsharish20
    New Member
    • Apr 2007
    • 14

    Shape coordinates logic

    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.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by nsharish20
    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.
    From what I could see from your formulas they're all correct. Your last problem
    boils down to two numbers a and b and the question are they less apart (or more)
    than a small number epsilon.

    There are two main approaches to this:

    1) abs(a-b) < epsilon; this is the absolute tolerance and

    2) abs(a-b)/max(abs(a), abs(b)) < epsilon which is the relative tolerance.

    Pick your choice.

    kind regards,

    Jos

    Comment

    • nsharish20
      New Member
      • Apr 2007
      • 14

      #3
      I don't understand what you mean by a and b? I want to write IF conditional statements for the two cases. I have already written for one case that is if the sensor (small circle) is close to the edge of the larger circle by 0.01 from the inside, then that will be identified as X. This if my IF conditional statement. Please feel free to correct me

      IF(0<=ABS(SQRT( (X2-X1)^2+(Y2-Y1)^2) - ABS(R2-R1))<=0.01) THEN RETURN X

      The next case is if the small circle is very close to the edge of the large circle, then return X. But i can't use this statement. Any ideas?

      Thanks

      Comment

      Working...