1. ## Need Math Experts

Okay, there's got to be someone here who's taken a math class in the last millenium. I've already forgotten what little I used to know about it in the first place. Here's the problem

I need to find the equation of a circle given 2 points (x1, y1) and (x2,y2), plus the Radius (R) and the angle between the two points (theta)

the equation would look like this

(x - x0)^2 + (y - y0)^2 = R^2
where y0 and x0 are the center of the circle

All I remember how to do is calculate the equation given 3 points, but not 2 and the angle.
My goal is to find the location of any point on that circle in cartesian coordinates, given a different theta, so ideally I'd want the solution to look like

x = f(x1, x2, y1, y2, R, theta)
y = f(x1, x2, y1, y2, R, theta)

I know there are two real solutions to this problem, the center will lie on the line bisecting the line between the two points. I also know the direction of rotation of theta, so that should be able to narrow it down to a single solution. Please help, all my math books have disenegrated from old age.

2. ## Re: Need Math Experts

The answer here is to draw a diagram. Diagram here. I'll also describe it as best I can. I drew a diagram assuming that x2 &lt; x1, y2 &gt; y1, and 0 &lt; theta &lt; pi/4, so p2 is up and to the left of p1 and the center (hereafter c) is somewhere down and to the left of them. Don't worry too much about scale since this is a representative diagram.

Draw a line segment from p1 to p2. It should be tilted like \. Find its center and draw its perpendicular bisector. Following the assumptions made above, c should be down and to the left of the p1-p2 segment, so pick an arbitrary point on the perpendicular bisector and label it c (x0, y0). Connect c to p1 and p2, labeling the new line segments with length R. Now you should have an isosceles triangle pointing down-left. Its base is the p1-p2 segment.

Using the Pythagorean theorem, the p1-p2 segment has length ((x1-x2)^2 + (y1-y2)^2)^(1/2), and the length of the perpendicular bisector between c and the base is (R^2 - 1/4*((x1-x2)^2 + (y1-y2)^2))^(1/2).

Now, that's all I could get before running into grungy Cartesian coordinate equations for the lines. I'll post again when I figure those out.

Keep in mind that this solution may not work if any of the original assumptions do not hold. It should be relatively easy to work through the steps until you find what's broken, though.

Edited by Flatscan (02/14/04 03:18 PM) to add diagram. Thanks logicnerd411!

3. ## Re: Need Math Experts

Flatscan, if you still need to host an image, you can look below at my signature to find some. [img]/ubbthreads/images/graemlins/tongue.gif[/img]

//Dan

4. ## Re: Need Math Experts

Thanks, Dan. I'll go whip up some B/W gifs and upload them there.

Diagram of segment slopes
Equations to solve for center coordinates
Angles, incorporating theta theta1 calculation sloppy! Use with care.

5. ## Re: Need Math Experts

[ QUOTE ]
logicnerd411 said:
Flatscan, if you still need to host an image, you can look below at my signature to find some. [img]/ubbthreads/images/graemlins/tongue.gif[/img]

//Dan

[/ QUOTE ]

I tried 2A-using IE-doesn't work. [img]/ubbthreads/images/graemlins/smoker5.gif[/img]

We really do need an alternative to Imagestation-they suck.

Rich

6. ## Re: Need Math Experts

There is an easier, much nicer solution using trigonometry. However, the complete solution is left as an exercise for the reader. [img]/ubbthreads/images/graemlins/grin.gif[/img] I'm around a third of the way through and didn't feel like continuing. Basic algebra should be enough to finish it off, though.

Angles, incorporating theta, definitions of theta0 and theta1. theta0 is given in the statement of the problem as theta. theta1 definition sloppy! Use with care.
Solution using trigonometry

If anyone finds errors in any part of this, post in the thread, and I'll fix the diagram or equation when I see it.

7. ## Re: Need Math Experts

Flatscan,
you must still be in school to remember all this. I ended up finding a solution after surfing the web all morning to refresh my trig skills. I think it works, I haven't actually tried it yet. But I went along the same way you were going, but I kept getting stuck at the same point. I won't bore you with the details, but here are the problems I encountered:

Theta = angle between two points
1) Cos (theta + theta1) - Cos (theta1) = Constant

Couldn't reduce the equation to solve for theta1

2) Xo, Yo: I couldn't isolate them in an equation to solve for either of them, I still ended up with Xo is a function of Yo, and vice versa. three unknowns, Xo, Yo, and theta1. Because although the chord distance bewteen P1 and P2 and the Radius stay constant, the actual XY coordinates are dependent on theta1. The solution is actually right there in front of me, just took me a very long time to see it and a very big sketch to see it.

8. ## Re: Need Math Experts

[ QUOTE ]
InTheDark said:...My goal is to find the location of any point on that circle in cartesian coordinates, given a different theta, so ideally I'd want the solution to look like

x = f(x1, x2, y1, y2, R, theta)
y = f(x1, x2, y1, y2, R, theta)

I know there are two real solutions to this problem, the center will lie on the line bisecting the line between the two points. I also know the direction of rotation of theta, so that should be able to narrow it down to a single solution...

[/ QUOTE ]

I don't see how you can get a solution of this form. x and y are just general points along the circle, so that given x1, x2, y1, y2, R, and theta, x and y are not specified uniquely. In fact, they are coupled, so that if you were able to solve explicitly for either x or y, you would have solutions of the form

x = f(x1,x2,y1,y2,R,theta,y)
y = g(x1,x2,y1,y2,R,theta,x).

Personally, I would settle for an implicitly defined solution. Something of the form you had above: (x-x0)^2 + (y-y0)^2 = R^2, where neither x nor y is solved for explicitly, and where x0 and y0 are eliminated in favor of x1,x2,y1,y2,R. In such a case, theta is probably unnecessary, since it merely determines which of the 2 circles you're talking about. I would expect that the value of theta could be reserved as a separate matter, and would only arise when you attempt to specify which of the two roots of the (quadratic) equation you want.

9. ## Re: Need Math Experts

Okay, the solution I had didn't work. But I think I found a different one. I know there has to be a solution for this, it just wasn't as simple as I thought. Since I can't show pictures, I'll use what flatscan has so elegantly drawn up in his angles gif.

x1, y1, x2, y2, and theta are all given. But instead of using theta1 as the angle of the line from the center to point1, it's easier to bisect the chord between the two points and use +/- (theta/2) to relate the points (you'll see why later)

So,
x1 = x0 + R cos (theta1 - theta/2)
x2 = etc....

The problem was that theta1 was another unknown that is introduced into this equation. If we knew theta1, then we could narrow the solution down to two choices. But theta1 can be determined from P1 and P2, it's at right angles to the slope of the line connecting the two (which is why we bisected that chord).

so,
Theta1 = f(x1,y1,x2,y2)
R = g(x1,y1,x2,y2,theta)
x0 = h(x,R,theta, theta1)
y0 = j((y,R,theta, theta1)

I didn't write out all the equations here, but is there a flaw in this logic? I did a quick check, it works, but I'm still having trouble with theta1, it doesn't always calculate right. too much math for today my brain is tired.

10. ## Re: Need Math Experts

My quick take on it comes up with two equations and two unknowns. Sorry, I don't have a diagram; I will try to explain it in words.

I noticed that the tangent of the original two points (x1,y1) and (x2,y2) is exactly the same as the tangent of the two points (x0,y0) and ((x1+x2)/2,(y1+y2)/2). (This last coordinate is the midpoint between (x1,y1) and (x2,y2).) This provides one equation:

(y2-y1)/(x2-x1) = ((x2+x1)/2-x0)/((y2+y1)/2-y0)

The second equation is knowing the equation of the circle:

(x1-x0)^2 + (y1-y0)^2 = R^2.

I don't have time to expand these out, however. The idea is to solve for x0 and y0.

nisshin

11. ## Re: Need Math Experts

[ QUOTE ]
InTheDark said:
Flatscan, you must still be in school to remember all this.

[/ QUOTE ]

Well, yes. [img]/ubbthreads/images/graemlins/grin.gif[/img] However, the last time I took a class that actually required this sort of math on a regular basis was around 4 years ago. I guess that's not too long in the big scheme of things, but I expected that I would have forgotten more. It's sort of why I went immediately for segment length and slope calculations instead of looking at the diagram for trigonometric relationships.

One big thing that I forgot to mention: the definition of theta1 is sloppy. Two things to note: the input fraction needs to be in the domain of sin^-1 or cos^-1 (negate it if necessary), and the output sign should be checked against which quadrant p1 is in relative to c (I think it's sufficient to negate it if and only if you negated the input).

[img]/ubbthreads/images/graemlins/help.gif[/img]InTheDark[img]/ubbthreads/images/graemlins/help.gif[/img] I need a definition of the variable theta (not the initial theta that I renamed theta0), as I assumed it to be the angle from p1 to new point, without any good reason.

[ QUOTE ]
InTheDark said:
Theta = angle between two points
1) Cos (theta + theta1) - Cos (theta1) = Constant

Couldn't reduce the equation to solve for theta1

[/ QUOTE ]

I didn't find this to be the case. To check, I put y = cos(pi/8 + x) - cos(x) and y = cos(x + pi/8) - cos (pi/8) into my graphing calculator, and both functions changed with x. Therefore, it's not a constant if either theta or theta1 varies. I'm reasonably sure that there will be no problems with this unless theta = 0 (theta = pi doesn't cause problems, I think).

[ QUOTE ]
InTheDark said:
2) Xo, Yo: I couldn't isolate them in an equation to solve for either of them, I still ended up with Xo is a function of Yo, and vice versa. three unknowns, Xo, Yo, and theta1. Because although the chord distance bewteen P1 and P2 and the Radius stay constant, the actual XY coordinates are dependent on theta1. The solution is actually right there in front of me, just took me a very long time to see it and a very big sketch to see it.

[/ QUOTE ]

I think it's possible to derive x0, y0 before ever introducing theta1. If you follow my original (i.e. the segment length, slope method) steps, that's what I did. I created theta1 to have an easy way of defining your desired functions.

[ QUOTE ]
Lux Luthor said:
I don't see how you can get a solution of this form. x and y are just general points along the circle, so that given x1, x2, y1, y2, R, and theta, x and y are not specified uniquely. In fact, they are coupled, so that if you were able to solve explicitly for either x or y, you would have solutions of the form

x = f(x1,x2,y1,y2,R,theta,y)
y = g(x1,x2,y1,y2,R,theta,x).

[/ QUOTE ]

Good point. My interpretation of what InTheDark wants is this (note the explicit addition of theta0 and the assumption of what theta is):

Given x1, x2, y1, y2, R, theta0 as constant:
x = f(theta)
y = g(theta)

12. ## Re: Need Math Experts

I think I have it. No I didn't solve it, but I think someone else did.

http://mathforum.org/library/drmath/view/53179.html

I haven't checked it, but I'll assume it's right.

Flatscan,
Grahping calculators? Wow, I had almost forgotten they had graphing calculators. I used to be a whiz with one, I probably still have the high score on pacman on my friends calculator. I didn't know they could be used for math though. [img]/ubbthreads/images/graemlins/icon3.gif[/img] I guess if I had paid attention in math class, I wouldn't be asking these questions.

To clarify, Theta 1 is the angle that bisects P1 and P2. so if P1 were at 0 degrees and P2 was at 60 degrees, then theta 1 would be 30. Theta is the angle between P1 and P2, in this case that would be 60. Also, when I said I couldn't reduce the equation, I meant I just didn't know how to calculate theta. For example

Cos (theta - 10) - cos (theta) = constant

How can you explicitly solve for theta? I'm sure you could keep iterating until you found the right one (which is what your calculator is doing), but I didn't know if there was an easier solution that I could sove on paper.

[ QUOTE ]

Lux Luthor said:
I don't see how you can get a solution of this form. x and y are just general points along the circle, so that given x1, x2, y1, y2, R, and theta, x and y are not specified uniquely. In fact, they are coupled, so that if you were able to solve explicitly for either x or y, you would have solutions of the form

[/ QUOTE ]

In theory, I think you should be able to solve for X and Y, since the coordiates of P1 and P2 are two distinct points and you know the radius, then that alone is enough to narrow it down to two solutions. P1 and P2 can't be just any points along the circle, they are separated by a distance D, and since you can calculate the slope of the line, that determines where the points are. The direction of theta should be the last equation needed to determine which solution is correct. Of course I couldn't solve it, but it just seems like it's possible

13. ## Re: Need Math Experts

I think I have a trigonometric solution (but I haven't tried it yet):

x0 = [(x1+x2) - (y2-y1)cot(theta/2)]/2

or

x0 = [(x1+x2) + (y2-y1)cot(theta/2)]/2

and

y0 = [(y2+y1) - (x2-x1)cot(theta/2)]/2

or

y0 = [(y2+y1) + (x2-x1)cot(theta/2)]/2

The way I derived these equations are as follows (sorry, I don't know how to upload diagrams).

I imagined three right triangles. I will use Flatscan's "Diagram of Segment Slopes." The first right triangle has points p1, p2, and (x2,y1). The second triangle has points p2, c, and ((x1+x2)/2, (y1+y2)/2). The third triangle has points c, ((x1+x2)/2, (y1+y2)/2), and ((x1+x2)/2,y0).

We make a new angle phi, which is the angle between line segment p1---p2 and p1---(x2,y1). This is also the same angle between the line segments c---((x1+x2)/2,(y1+y2)/2) and ((x1+x2)/2,(y1+y2)/2)---((x1+x2)/2,y0).

The length of segment c---((x1+x2)/2,(y1+y2))/2 is simply Rcos(theta/2). Thus, to find x0 in relation to (x1+x2)/2, we need to have the length of c---((x1+x2)/2,y0). But this length is given by Rcos(theta/2)sin(phi).

Now we need to know sin(phi). The hypotenuse of the first triangle, p1---p2, is given by 2*Rsin(theta/2). The length of p2---(x2,y1) is simply the difference in y-coordinates, namely (y2-y1). Hence, sin(phi) = (y2-y1)/(2*Rsin(theta/2)). Putting all these lengths together, we have:

x0 = (x1+x2)/2 - Rcos(theta/2)sin(phi)
= (x1+x2)/2 - Rcos(theta/2)(y2-y1)/(2*Rsin(theta/2))
= (x1+x2)/2 - (y2-y1)*(Rcos(theta/2))/(Rsin(theta/2))/2
= [(x1+x2) - (y2-y1)*cot(theta/2)]/2

The equation for y0 is similarly derived.

Notice that we no longer need R in the equation, as the known quantities are over-specified.

nisshin

14. ## Re: Need Math Experts

Okay, I think I drew my diagram right of the solution you're describing. But there are two problems

1) Sin(phi), shouldn't it be (x2-x1)/2*Rsin(theta/2) ? Maybe I mislabled something in my diagram. But as x2-x1 approach 0, sine(phi) should also approach zero.

2) The solution does not account for the second solution to the problem. There will be two solutions for any given two points (assuming a solution is possible), unless chord = 2R, then theta = 180 and there's only one circle that can fit between the two points. But for any two points, there should be a two circles and two centers that will satisfy the conditions.

Depending on how you solve it, either R or theta can be eliminated, but not both. two points only determine a line, so it needs one other variable to give you the equation of a circle. but R = f(theta) or theta = f(R) so those two are interchangable.

The good news is that the solution I found works. It's a lot more complicated than I want, but a lot simpler than the ones I was getting.

15. ## Re: Need Math Experts

[ QUOTE ]
I think I have it. No I didn't solve it, but I think someone else did.

http://mathforum.org/library/drmath/view/53179.html

I haven't checked it, but I'll assume it's right.

[/ QUOTE ]

The link above does in fact provide the correct solution. I didn't go through the attempts you guys made above very carefully, but it seems that after the initial recognition that there are TWO circles to be found, no one provided for that fact in their resulting equations! The math person in the link did so from the beginning, and despite the apparent increase in complexity in doing this, it is the most elegant solution to a rather annoying problem.

16. ## Re: Need Math Experts

hmmm. theta being given threw me a little, as its magnitude can be derived from the points' locations and R. I incorrectly assumed that it was well-specified as "the angle from p1 to p2," i.e. with a relevant sign that unambiguously indicates which one of the two circles.

now wishing that I used those couple hours for something else [img]/ubbthreads/images/graemlins/icon23.gif[/img]

17. ## Re: Need Math Experts

[ QUOTE ]
Flatscan said:
hmmm. theta being given threw me a little, as its magnitude can be derived from the points' locations and R. I incorrectly assumed that it was well-specified as "the angle from p1 to p2," i.e. with a relevant sign that unambiguously indicates which one of the two circles.

now wishing that I used those couple hours for something else [img]/ubbthreads/images/graemlins/icon23.gif[/img]

[/ QUOTE ]

A negative angle only has meaning if you have a reference zero and positive definition direction, such as the x-positive-axis being zero, counter-clockwise positive. There is no such thing as the angle between two points. The angle between two lines is always positive. I mean, think about it, if you have two arbitrary points in space and four lines of length R which start at those points and meet to form two points of intersection, how could you possibly define one angle to be + theta, and the other to be - theta ? If you have a scheme for doing this without ambiguity, I would no joke LOVE to hear it.

As for wasting time--nah--time spent on math is NEVER wasted. It's all good. It would have taken me a good bit of time to solve this problem (I suspect), but it was still kind of disappointing to see that the answer had already been found. I love a math challenge.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•