View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] mahadevan.swamy@gmail.com is offline
external usenet poster
 
Posts: 59
Default Writing a logic for shape coordinates

Thank you for your solution. I am very new to VB and I don't know how
to use your solution. I was hoping to write a small formula to perform
some calculation. I would like to fill you with some details on this
coordinates problem.

I have a big circle which consists of 32 small circles oriented in
different places. These circles are sensors that has to read a part.
When the blueprint of the part is placed on top of these sensors,
these sensors should read the part. This blueprint consists of holes
and slots (rectangle with a semi-circle) in the drawing and where ever
there is a hole or slot on top of the sensor, the sensor should read
0, 1 or X. I want to check if the hole is in the range of the sensor,
the value should be 0. If the hole is out of range, the value should
be 1. If the hole is blocking the sensor or very closely touching the
sensor, the value should be X.

There is a bigger inner hole (pilot bore hole) in the part and all the
small holes (mounting holes, sensor holes etc..) are outside of this
big hole. This big hole has the coordinate (0,0,r) always. Some part
consists of slots which are connected to the bigger inner hole and
slot design is a rectangle with a semi-circle that we were discussing
about. The slot can be oriented at any angle.

There are two kinds of slot. One kind of slot looks like a semi-circle
and a rectangle together that is connected to the pilot bore hole.If
you want a picture of this, I can send it to you. I am given X, Y, and
R coordinate of the semi-circle. I am also given the radius of this
point from (0,0). The other kind of slot looks like a wide rectangle
but is chamfered in the two corners. For this, I am given width of the
rectangle, radius of the chamfer and distance from the end of the slot
to the origin. The slot can be oriented anywhere on the part. I have
another information which may or may not be useful. The mounting holes
(small holes outside bigger inner hole) has a center line radius
measured with respect to the origin and the slot cannot extend beyond
this radius (for the rectangle part). Small part of the semi-circle is
extended beyond this radius but I am not given the dimension of how
much it has been extended.

I have a row that consists of X, Y and R coordinates for each hole in
the part and a list of sensors with their X,Y and R coordinates. I am
trying to build a logic that will help me to see whether the sensor is
in the range of the hole or slot and execute decisions to produce some
results. I would appreciate your help on this. Thanks

Mahadevan Swamy




On Apr 4, 1:04 pm, Joel wrote:
See my thoughts below.

Sub Littlecircle()

'solution
' Check if Little circle is completly outside or completly inside
' otherwise it is it is mid

'Given rectangle width = RectW
'Given rectangle height = RectH
'Rectangle bottom left corner at (RectX,RectY)

'Given Circle on top of rectangle
'Circle Radius = RectW/2
'Center of circle at (X + (RectW/2)), RectH)

'Little circle radius = LittleR
'Little circle location = (LittleX,LittleY)

'first eliminate obvious outside evvents
'Little circle extends beyond bottom of rectangle
If LittleY - LittleR < RectY Then
Results = "Out"
Exit Sub
End If
'Little circle extends beyond left of rectangle
If LittleX - LittleR < RectX Then
Results = "Out"
Exit Sub
End If
'Little circle extends beyond right of rectangle
If LittleX + LittleR (RectX + RectW) Then
Results = "Out"
Exit Sub
End If
'Next check if little circle is above rectangle
If LittleY (RectY + RectH) Then

'compute distance from center of semicircle to center little circle
xdistance = LittleX - (RectX + (RectW / 2))
ydistance = LittleY - RectY
distance = Sqr((xdistance * xdistance) + (ydistance * xdistance))

'check if outside circle
If distance RectW / 2 Then
Results = "Out"
Exit Sub
End If

'check if it is inside semi-circle
If distance + LittleR < (RectW / 2) Then

'make sure Little circle doesn't extend below rectangle
If LittleY - LittleR < RectY Then

Results = "In"
Exit Sub
End If
End If

End If

'Now the only thing to check is if Little circle inside rectangle
'Little circle inside bottom of rectangle
If LittleY - LittleR RectY Then
Results = "In"
Exit Sub
End If
'Little circle inside left side of rectangle
If LittleX - LittleR RectX Then
Results = "In"
Exit Sub
End If
'Little circle inside right side of rectangle
If LittleX + LittleR < (RectX + RectW) Then
Results = "In"
Exit Sub
End If

Results = "Mid"

End Sub

" wrote:
Hi,


In an excel spreadsheet, I have the coordinates of a small circle and
another shape which is a semi-circle and a rectange together. For
this
shape (semi-circle and rectange), I have the X and Y coordinates and
R
coordinate for the semi-circle. I also have the absolute radius of
this shape measured from (0,0). For the small circle, I am given X,Y,
and R coordinates.


The objective is to check whether the small circle is in the range of
this shape and assign a particular value: "IN", "OUT", or "MID". I
would appreciate if any one can help me build a logic on this. Thanks


Swamy