Google Answers Logo
View Question
 
Q: This is motion control / geometry problem ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: This is motion control / geometry problem
Category: Science > Math
Asked by: norcalcoder-ga
List Price: $20.00
Posted: 02 Dec 2005 14:19 PST
Expires: 01 Jan 2006 14:19 PST
Question ID: 600675
This is motion control / geometry problem:

Need to find the cartesian coordinates of a circles center given 2
points on it's perimeter (arc endpoints) and the radius of the circle.

Would prefer the answer in both equation form along with programmatic
snippet example like Visual Basic or C.
Answer  
Subject: Re: This is motion control / geometry problem
Answered By: hedgie-ga on 03 Dec 2005 20:14 PST
Rated:5 out of 5 stars
 
Hello Norcal Coder

  Two points you have, lets's call them Pu and Pl  (upper and lower),
   define  a third point, half way between them, which we will call P0 .
   We will place the center of coordinates to P0  so, that both Pu and Pl
   are on the y axis.
 You are seeking point C, such that distance to Pl, and to Pu is equal to
radius r.  Due to symetry, we know that C is on the x axis : C= (0,c)
  That means y coordinate is 0 , we seek c = the x coordiante coordinate: 
  
           c^2= r* r - h * h   (Pythagoras theorem for triangle ( Pl P0 C )

 c^2 = c *c , as you take square root, you get + and - values, 

We have  two solutions if h<r, no solution if h>r, as prophesied in the comment.

 For coding, you just need to know that sqrt meand square root.

 Rating appreciated.

Hedgie

Request for Answer Clarification by norcalcoder-ga on 04 Dec 2005 11:40 PST
I kept finding more complicated solutions involving solving algabraic
equations for 2 circles of the same radius drawn with their centers at
the 2 points I have, so where they overlap are the possible center
points of the 2 cirles I'm looking for.

Your solution is much more elegant, one thing though is I do not have
the luxery of placing the 2 points on the y axis such that thier
midpoint cooincides with the origin of xy.

I spent a few hours on this and finally decided to post here,
unfortunately, shortly after I did, I found an answer on Dr. Math
website. He's calling it "vector theory".

Here it is:

***********************************************************
'Date: 01/24/97 at 21:15:10
'From: Sherri McClung
'Subject: Find center of circle
'
'Please help me find a formula to obtain the center coordinates of a
'circle if I know two points on the circle and its radius.  (There
'should be two solutions)
'
'Thank you!
'
'
'------------------------------------------------------------------------------'
'
'Date: 01/26/97 at 16:06:22
'From: Doctor Mitteldorf
'Subject: Re: Find center of circle
'
'Dear Sherri,
'
'Whenever I 'm faced with a problem like this, I try to go back to the
'definitions and see how they help.  If I'm looking for the center of a
'circle of radius r, then I'm looking for a point a distance r away.
'The distance between (x1, y1) and (x, y) is given by Pythagoras:
'
'             sqrt ((x - x1) ^ 2 + (y - y1) ^ 2)
'
'Let's think of (x1, y1) and (x2, y2) as our two circle points, and let
'(x, y) be the point we're looking for.  Then this is the equation that
'says the distance from the first point is r:
'
'             (x-x1)^2 + (y-y1)^2 = r^2
'
'This is the equation that says the distance from the second point
'is r:
'
'             (x-x2)^2 + (y-y2)^2 = r^2
'
'I wrote them with both sides squared because I thought it might be
'easier to work with the two equations if they didn't have the square
'roots in them.
'
'The next step is to combine these two equations algebraically and make
'an equation for x and an equation for y out of them.  Usually, a
'surefire approach would be to solve one equation for y, and then
'substitute the expression you get wherever you see a y in the other
'equation.I  'm pretty sure that will work, but you'll be doing a lot
'of algebraic manipulation with square roots.
'
'So Here 's another idea for solving the problem. It should lead to the
'same answer and the algebra will be less tedious.  This method,
'however, uses some fancy ideas from "vector theory", which are
'probably strange and unfamiliar to you.
'
'Think of the geometry. You know that for any two points there's a
'"mirror line" that goes halfway between them. Technically, the line
'consists of the locus of all points that are equidistant from your two
'circle points; you can think of the line as a mirror where each of
'your two points appears as a reflection of the other.
'
'Well, this line will help us a lot in constructing our center, because
'we know that the center is on the line AND because we can use
'Pythagoras to tell us where on the line the point is.  Here's how we
'can do all that with algebra.
'
'First, find the distance between points 1 and 2.  We'll call that q,
'and it's given by sqrt((x2-x1)^2 + (y2-y1)^2).
'
'Second, find the point halfway between your two points.  We'll call it
'(x3, y3).  x3 = (x1+x2)/2  and  y3 = (y1+y2)/2.
'
'Now find the direction of the line between point 1 and point 2.  That
'direction is (x1-x2, y1-y2).
'
'What we really want to know is the direction of the mirror line, which
'is perpendicular to the line between point 1 and point 2.
'
'Here 's a crucial trick: you can find the direction of a perpendicular
'to a line just by swapping x with y and changing the sign of one.  In
'other words, if the direction of the joining line was (x1-x2, y1-y2)
'then the direction of the mirror line is (y1-y2,x2-x1).
'
'It will be helpful to "normalize" our direction which means to make
'the length of the line equal to 1.  You do this just by dividing both
'the (y1-y2) and the (x2-x1) by q.
'
'The two circle centers will both be on the mirror line, and we can use
'geometry to find how far they are from the point (x3,y3):  First
'notice that the distance from point (x3,y3) to either point 1 or point
'2 is just half of q.  Then the distance to move along the mirror line
'is:
'                      sqrt (r ^ 2 - (q / 2) ^ 2)
'
'Move up the mirror line by adding a multiple of the direction line to
'the point (x3,y3) or move down the mirror line by subtracting the same
'multiple.
'
'One answer will be:
'
'x = x3 + sqrt(r ^ 2 - (q / 2) ^ 2) * (y1 - y2) / q
'y = y3 + sqrt(r ^ 2 - (q / 2) ^ 2) * (x2 - x1) / q
'
'The other will be:
'
'x = x3 - sqrt(r ^ 2 - (q / 2) ^ 2) * (y1 - y2) / q
'y = y3 - sqrt(r ^ 2 - (q / 2) ^ 2) * (x2 - x1) / q
'
'As I write this, I realize how complicated the ideas in vector theory
'can be, and I don't expect you'll be able to follow this.  If you're
'interested enough to devote some time to it, ask a math teacher for
'help.
'
'Or make a start with it, get as far as you can, and write back to Dr
'Math if you get stuck.
'
'-Doctor Mitteldorf,  The Math Forum
' Check out our web site!

***********************************************************

In our machine we know know approximately where the part is (in this
case it's a silicon wafer), so I can figure out which of the 2 circles
I need by finding the one whose center is closest to the center of the
MOTION STAGE thats moving the wafer.

Hedgie, what do you mean "For coding, you just need to know that sqrt
meand square root".

For coding I was not looking forward to coding "doing a lot of
algebraic manipulation with square roots". Which looked like the only
option up to this point.

I plugged this into the code and had no problems:

'First, find the distance between points 1 and 2.  We'll call that q,
'and it's given by sqrt((x2-x1)^2 + (y2-y1)^2).
'
'Second, find the point halfway between your two points.  We'll call it
'(x3, y3).  x3 = (x1+x2)/2  and  y3 = (y1+y2)/2.
'
'One answer will be:
'
'x = x3 + sqrt(r ^ 2 - (q / 2) ^ 2) * (y1 - y2) / q
'y = y3 + sqrt(r ^ 2 - (q / 2) ^ 2) * (x2 - x1) / q
'
'The other will be:
'
'x = x3 - sqrt(r ^ 2 - (q / 2) ^ 2) * (y1 - y2) / q
'y = y3 - sqrt(r ^ 2 - (q / 2) ^ 2) * (x2 - x1) / q

As I know that one of the 2 points I'm given will always be in the
upper left (-x,+y) quadrant and the other will always be in the upper
right (+x,+y) quadrant and the center will always be in the -y
direction relative to the 2 points I know I need the second possible
answer.

Comments appreciated.

Thanks.

Clarification of Answer by hedgie-ga on 04 Dec 2005 19:08 PST
Coder
      There are many equivalent ways of solving such problems.
      The one you found is just as good.

 I just want to comment on your statement: 

 "I do not have the luxury of placing the 2 points on the y axis.."

 since it may help you next time in similar situations:

 To pick a coordinate system, the way you want, is not a luxury,
 it's more  like a fundamental right. You can do the calculation
 in any system, and have several systema and transform the results from one
 to another,  and will vome out the same way. To put it differently,
 'it just a way of speeking': For any two points, you can find the
 center point, and you can construct the triangle Pl P0 C
and do the calculation. Instead of calling it 'x axis', you can just
call 'line starting at the center,  in direction 90 degrees to the Pl, P0 etc'
 To call these lines y and x axis, etc is just a way of talking, which
is often useful.
 Analytical geometry, or vectors, are  just a convenient terminology.
norcalcoder-ga rated this answer:5 out of 5 stars
Good answer and follow up.

Comments  
Subject: Re: This is motion control / geometry problem
From: hfshaw-ga on 02 Dec 2005 16:54 PST
 
This problem is nonunique.  In general, given two points, there are
TWO circles with radius R that contain those points.  To see this,
make two dots on a piece of paper that are separated by less than the
diameter of a coin you have in your pocket.  Now place the coin so
that the two dots lie on the perimeter.  Note that there are two ways
to do this.

Only if you draw the dots so that they are separated by exactly the
diameter of the coin is there a unique solution.  (And, of course, if
you separate the dots by more than the diameter of the coin, then
there are no solutions.)

One needs three points on the perimeter (and you then don't need to
know the radius) to specify a circle uniquely in 2-D.  A method for
doing this can be found at
<http://astronomy.swin.edu.au/~pbourke/geometry/circlefrom3/>.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy