How can I calculate the point(s) where 2 circles cross
I seem to be unable to tell this computer to calculate the crossing- points of circles. I have the centreposition and radius of the circles calculated, now I need to claculate the crossings.
I know I have to use to formula Radius=SQR( (x+CenterX)^2 +(y+Centery)^2). But whow would I do that in code??
I know I'm getting stupid, but........
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
If they cross consider the connecting line from Centre1 to circle2 a one side of a triangle, the other sider are the radus1 and Radius2. So you've got 3 sides of a triangle, so you can calculate the angles of this triangle.
To calculate the crossing points just use the direction from Circle1 to Circle2, add/subtract the angle from the triangle in Centre1. This will give the direction to both (or to the one and only) crossingpoint. The distance is of course Radius 1.
That looks like a solution which I can easily put into code.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
Re: How can I calculate the point(s) where 2 circles cross
The easy approach for me consists in applying a transformation of coordinates, doing the calculation for a special case and rolling back the transformation.
For example, you can make a x,y shift such that the new coordinate origin is at the center of circle 1 (radius R) and next apply a rotation such that the center of circle 2 (radius r) lies on the positive x axis at a distance a from the origin. Then it's very straightforward to arrive at these coordinates for the points of intersection:
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Re: How can I calculate the point(s) where 2 circles cross
Originally Posted by opus
If they cross consider the connecting line from Centre1 to circle2 a one side of a triangle, the other sider are the radus1 and Radius2. So you've got 3 sides of a triangle, so you can calculate the angles of this triangle.
uhhh.
I've spent most of today looking at this (I have a piece of a4 with doodles of triangles and circles on it).
I can see how you get the distance from circleA to circleB, and using the radii as the other two sides of the triangle. However (and being its been a long time since I was at school) I cannot see how you would get the angles so easily...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
Thanks that link helped.
Seems as I get older there is more crap and its harder to find the best search criteria
Right. So I've coded up the solving of the triangle woo.
Now to use that to find the proper position(s) of the cross points...
Looking at my sketched diagram, I uh cannot see any right angles :/
Christ, never knew I had forgotten maths so badly :/
Can you point me to another link for getting the co-ordinates.
I have a form (in Excel) which is accepting x1,y1, x2,y2 r1,r2 and hopefully will return one or two cross points of the circle (I don't want to look for more than that )
EDIT: I found it... second triangle angle added to the one I've just found can produce the co-ordinates
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
Right, something has gone wrong with it and I cannot even get those result I previously had.
I'm attaching the spreadsheet (up to you if you want to look and download).
Any flaws in my logic I would appreciate the pointers
* Note - the drawing part doesn't appearr to work right, which is one reason I think the values are wrong...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
You got some errors in the code,
I changed the ArcCos Function(some brackets) and you didn't check wether your point1 was left or right of point2, therefore your third point could be outside the desired triangle, I changed the code for you.
VB Code:
'---------
'---- NOTE: Sticking with R A D I A N S as the resulting angles!!
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
Hi,
An updated spreadsheet.
The test data I've used is in the top right, the green appears to work, only the red one doesn't (not sure why yet - but this means that there are more problems inside it).
Any advice?
Oh the direction thing (x1 to x2 etc) I got around and use a direction angle, which when past a certain point becomes a negative sin/cos... And works for all but the one test.
I'm gonna take a break from it and try again tomorrow probably.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
Weird...
Ok, here's an updated file and the final spreadsheet/code.
I tried uploading it before, but I guess it never made it (last workplace had a crap net connection after 10am...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
Still weird, but WindowsXP tells me it doesn'T "know" the method for kompressing.
I still can download and open the first .Zip file, but the last two i can't.
I'm so sorry...............................
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
Hi,
I fixed some of the logics 8espacially the calculation of direction and of the angle.
you had lots of mixups with Radians and degree.
And you still have lots of variables that are not needed.
For the calculation of the Angle, I went the easy way, and just calculated one angle and used this one for both crossing points.
In the drawing I changed the Offset and the fact that you were adding the Y-Value, although VB "counts" Y the other way (downward is +!)
Last edited by opus; Jul 18th, 2007 at 02:52 AM.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Re: How can I calculate the point(s) where 2 circles cross
Thanks for that. Thought it was working ok - but I guess not huh
Well that was brain stretching.. time for some relaxing -----> Data entry - very little thought required
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...