Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writing a logic for shape coordinates
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writing a logic for shape coordinates
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writing a logic for shape coordinates
There are atleast 1000 parts which consists of different patterns.
Some consists of mounting holes all over the place or mounting holes and slots. The data structure that I am looking at is that there should be one column for all part numbers and 32 columns for the 32 sensors. For a certain part design, value 0 will go for sensors that detects a hole or a slot (uncovered), value 1 goes for sensors that are covered and value X will go for sensors that are blocked or very closely touching (blocking) the diameter (it is like an eclipse). In another worksheet, in one row or one column, I would have the X,Y, and R coordinates of each hole and some necessary info for the slot hole. Also when I change the co-ordinates of the sensor, it should give me accurate information. The first phase of the problem is complete. The design used in this problem was that there were mounting holes over the place and no slots. So, the sensors can read whether the holes are in their range and assign a value and thus we'll know whether it is covered or not. Now there is a new design with two types of slot and it is a bit tricky to figure out a logic. Since you have some good background in geometry and programing I could use your help. If you need to visualize what I am talking about, please tell me and I'll send you the file to your email. Thanks Mahadevan Swamy On Apr 5, 7:34 am, Joel wrote: I understand your problems after reading your lastest posting. I'm an electrical engineer, prgrammer, and have worked a lot with mechanical engineers. i also have a very strong geometry background. You need to read the comment in the code I sent you. The comments are more important than the code. I tried to explain how to solve the problem, not the actual solution. It is very hard to figure out if one geometric figure is partially inside and outside of another geometric figure. it is easier to see if it is completely inside and completely outside. If it is neither inside or outside then it must be overlappings. There isn't a single formula that can be used. and then you problem is more complicated than I originally thought. First your semicircles radius have different arc lengths. Second semicircle can be on any side of the rectangle. as I said in the comments of the code, Check for the 1's and 0's. What is left is the X's. I would be glad to assist is this problems. Use my email at work . Lets take the simple solution first and see if solves the problem. Lets convert the slots are rectangles. Find the maximum X,Y coordinates and X,Y position of the slots and check to see if the rectangles can be seen by each of the sensors. The problem turnout to be pretty simple. You only have to check the four corners or a rectangle to see if a rectangle is outside of a larger circle. It is impossible for a rectangle which is inside a circle to have an edge outside and all four corners inside. The proof to this has to do with the shortest distance between 2 points is a straight line. An edge of a rectange is a straight line and therefore is the shortest distance. An arc of a circle is not a straight line and therefore must be longer than the straight line. For an edge of tthe rectangle to be outside the circle is a contradiction. The arc of the circle would have to be shorter than the side of the rectangle. " wrote: 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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writing a logic for shape coordinates
Send me the file with instructions. You last reply didn't tell me what I
needed to do. " wrote: There are atleast 1000 parts which consists of different patterns. Some consists of mounting holes all over the place or mounting holes and slots. The data structure that I am looking at is that there should be one column for all part numbers and 32 columns for the 32 sensors. For a certain part design, value 0 will go for sensors that detects a hole or a slot (uncovered), value 1 goes for sensors that are covered and value X will go for sensors that are blocked or very closely touching (blocking) the diameter (it is like an eclipse). In another worksheet, in one row or one column, I would have the X,Y, and R coordinates of each hole and some necessary info for the slot hole. Also when I change the co-ordinates of the sensor, it should give me accurate information. The first phase of the problem is complete. The design used in this problem was that there were mounting holes over the place and no slots. So, the sensors can read whether the holes are in their range and assign a value and thus we'll know whether it is covered or not. Now there is a new design with two types of slot and it is a bit tricky to figure out a logic. Since you have some good background in geometry and programing I could use your help. If you need to visualize what I am talking about, please tell me and I'll send you the file to your email. Thanks Mahadevan Swamy On Apr 5, 7:34 am, Joel wrote: I understand your problems after reading your lastest posting. I'm an electrical engineer, prgrammer, and have worked a lot with mechanical engineers. i also have a very strong geometry background. You need to read the comment in the code I sent you. The comments are more important than the code. I tried to explain how to solve the problem, not the actual solution. It is very hard to figure out if one geometric figure is partially inside and outside of another geometric figure. it is easier to see if it is completely inside and completely outside. If it is neither inside or outside then it must be overlappings. There isn't a single formula that can be used. and then you problem is more complicated than I originally thought. First your semicircles radius have different arc lengths. Second semicircle can be on any side of the rectangle. as I said in the comments of the code, Check for the 1's and 0's. What is left is the X's. I would be glad to assist is this problems. Use my email at work . Lets take the simple solution first and see if solves the problem. Lets convert the slots are rectangles. Find the maximum X,Y coordinates and X,Y position of the slots and check to see if the rectangles can be seen by each of the sensors. The problem turnout to be pretty simple. You only have to check the four corners or a rectangle to see if a rectangle is outside of a larger circle. It is impossible for a rectangle which is inside a circle to have an edge outside and all four corners inside. The proof to this has to do with the shortest distance between 2 points is a straight line. An edge of a rectange is a straight line and therefore is the shortest distance. An arc of a circle is not a straight line and therefore must be longer than the straight line. For an edge of tthe rectangle to be outside the circle is a contradiction. The arc of the circle would have to be shorter than the side of the rectangle. " wrote: 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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writing a logic for shape coordinates
Hi,
I have sent the file to you. Mahadevan Swamy On Apr 6, 7:52 am, Joel wrote: Send me the file with instructions. You last reply didn't tell me what I needed to do. " wrote: There are atleast 1000 parts which consists of different patterns. Some consists of mounting holes all over the place or mounting holes and slots. The data structure that I am looking at is that there should be one column for all part numbers and 32 columns for the 32 sensors. For a certain part design, value 0 will go for sensors that detects a hole or a slot (uncovered), value 1 goes for sensors that are covered and value X will go for sensors that are blocked or very closely touching (blocking) the diameter (it is like an eclipse). In another worksheet, in one row or one column, I would have the X,Y, and R coordinates of each hole and some necessary info for the slot hole. Also when I change the co-ordinates of the sensor, it should give me accurate information. The first phase of the problem is complete. The design used in this problem was that there were mounting holes over the place and no slots. So, the sensors can read whether the holes are in their range and assign a value and thus we'll know whether it is covered or not. Now there is a new design with two types of slot and it is a bit tricky to figure out a logic. Since you have some good background in geometry and programing I could use your help. If you need to visualize what I am talking about, please tell me and I'll send you the file to your email. Thanks Mahadevan Swamy On Apr 5, 7:34 am, Joel wrote: I understand your problems after reading your lastest posting. I'm an electrical engineer, prgrammer, and have worked a lot with mechanical engineers. i also have a very strong geometry background. You need to read the comment in the code I sent you. The comments are more important than the code. I tried to explain how to solve the problem, not the actual solution. It is very hard to figure out if one geometric figure is partially inside and outside of another geometric figure. it is easier to see if it is completely inside and completely outside. If it is neither inside or outside then it must be overlappings. There isn't a single formula that can be used. and then you problem is more complicated than I originally thought. First your semicircles radius have different arc lengths. Second semicircle can be on any side of the rectangle. as I said in the comments of the code, Check for the 1's and 0's. What is left is the X's. I would be glad to assist is this problems. Use my email at work . Lets take the simple solution first and see if solves the problem. Lets convert the slots are rectangles. Find the maximum X,Y coordinates and X,Y position of the slots and check to see if the rectangles can be seen by each of the sensors. The problem turnout to be pretty simple. You only have to check the four corners or a rectangle to see if a rectangle is outside of a larger circle. It is impossible for a rectangle which is inside a circle to have an edge outside and all four corners inside. The proof to this has to do with the shortest distance between 2 points is a straight line. An edge of a rectange is a straight line and therefore is the shortest distance. An arc of a circle is not a straight line and therefore must be longer than the straight line. For an edge of tthe rectangle to be outside the circle is a contradiction. The arc of the circle would have to be shorter than the side of the rectangle. " wrote: 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 ... read more » |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Writing a logic for shape coordinates
This is the logic I have written for the slots being oriented at
different angles. The way I have numbered is starting with the top right corner of the rectangle and then top left corner of the rectangle. Conditions for getting 0 For 0 < angle < 90, x3<x<x2 y3<y<y2 x4<x<x1 y4<y<y1 For 90<angle<180 x1< x < x4 y4<y<y1 x2<x<x3 y3<y<y2 For 180<angle<270 x1<x<x4 y1<y<y4 x2<x<x3 y2<y<y3 For 270<angle<360 x4<x<x1 y1<y<y4 x2<x<x2 y2<y<y3 The two sets conditions are written for each angle if the sensor is out of range for the circle and in the range of rectangle at two places (left and right). I could put up a condition where if the row for slot is equal to 0, then prevent executing the function that I have written for slot or else if the sensor is in the range of the circle and rectangle, then execute the conditions that I have given above. Mahadevan Swamy On Apr 6, 8:24 pm, wrote: Hi, I have sent the file to you. Mahadevan Swamy On Apr 6, 7:52 am, Joel wrote: Send me the file with instructions. You last reply didn't tell me what I needed to do. " wrote: There are atleast 1000 parts which consists of different patterns. Some consists of mounting holes all over the place or mounting holes and slots. The data structure that I am looking at is that there should be one column for all part numbers and 32 columns for the 32 sensors. For a certain part design, value 0 will go for sensors that detects a hole or a slot (uncovered), value 1 goes for sensors that are covered and value X will go for sensors that are blocked or very closely touching (blocking) the diameter (it is like an eclipse). In another worksheet, in one row or one column, I would have the X,Y, and R coordinates of each hole and some necessary info for the slot hole. Also when I change the co-ordinates of the sensor, it should give me accurate information. The first phase of the problem is complete. The design used in this problem was that there were mounting holes over the place and no slots. So, the sensors can read whether the holes are in their range and assign a value and thus we'll know whether it is covered or not. Now there is a new design with two types of slot and it is a bit tricky to figure out a logic. Since you have some good background in geometry and programing I could use your help. If you need to visualize what I am talking about, please tell me and I'll send you the file to your email. Thanks Mahadevan Swamy On Apr 5, 7:34 am, Joel wrote: I understand your problems after reading your lastest posting. I'm an electrical engineer, prgrammer, and have worked a lot with mechanical engineers. i also have a very strong geometry background. You need to read the comment in the code I sent you. The comments are more important than the code. I tried to explain how to solve the problem, not the actual solution. It is very hard to figure out if one geometric figure is partially inside and outside of another geometric figure. it is easier to see if it is completely inside and completely outside. If it is neither inside or outside then it must be overlappings. There isn't a single formula that can be used. and then you problem is more complicated than I originally thought. First your semicircles radius have different arc lengths. Second semicircle can be on any side of the rectangle. as I said in the comments of the code, Check for the 1's and 0's. What is left is the X's. I would be glad to assist is this problems. Use my email at work . Lets take the simple solution first and see if solves the problem. Lets convert the slots are rectangles. Find the maximum X,Y coordinates and X,Y position of the slots and check to see if the rectangles can be seen by each of the sensors. The problem turnout to be pretty simple. You only have to check the four corners or a rectangle to see if a rectangle is outside of a larger circle. It is impossible for a rectangle which is inside a circle to have an edge outside and all four corners inside. The proof to this has to do with the shortest distance between 2 points is a straight line. An edge of a rectange is a straight line and therefore is the shortest distance. An arc of a circle is not a straight line and therefore must be longer than the straight line. For an edge of tthe rectangle to be outside the circle is a contradiction. The arc of the circle would have to be shorter than the side of the rectangle. " wrote: 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to dump freeform coordinates (a plot shape) | Charts and Charting in Excel | |||
Shape coordinates | Excel Discussion (Misc queries) | |||
convert x/y coordinates to a shape file to use in Cad? | Excel Discussion (Misc queries) | |||
Simple way to convert UTM ED50 coordinates to decimal coordinates? | Excel Programming | |||
Converting MouseDown Coordinates to Chart Point Coordinates | Excel Programming |