Re: Circle-line intersection
From: Arturo Magidin (magidin_at_math.berkeley.edu)
Date: 12/03/04
- Next message: tchow_at_lsa.umich.edu: "Re: Platonism"
- Previous message: W. Dale Hall: "Shiing-shen Chern (Chen Xingshen) passes away at 93"
- In reply to: Johannes Bergmark: "Circle-line intersection"
- Next in thread: Johannes Bergmark: "Re: Circle-line intersection"
- Reply: Johannes Bergmark: "Re: Circle-line intersection"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Dec 2004 21:07:15 +0000 (UTC)
In article <1ddb442c.0412031243.6c89b88@posting.google.com>,
Johannes Bergmark <johannes.bergmark@bredband.net> wrote:
>A line(L) intersects with a circle(C), tell me if something is wrong.
>All positions orients from circle position which is (0,0).
You might want to say what it is you are trying to do...
>t is what I want.
>L = A + (B-A)*t
>where D = B-A
There was no D so far....
You mean: L is a line going through the points A and B, and we obtain
it (by vector addition) as A + Dt, where D = (B-A) (A, B being vectors
with initial point at the origin and terminal point at the point A and
B, presumably, and t being a real number parameter...)
Is that right?
>Lx = cos(v)*R
>Ly = sin(v)*R
What are "Lx" and "Ly" supposed to mean? What is R? What is v?
I assume "Lx" means "the x coordinate of the point on the line", and
"Ly" means the y coordinate (as below you have Ax, Dx, Ay, Dy,
presumably being "x coordinate of A", "x coordinate of D", etc).
Meaning... you are trying to figure out the intersection? (x,y) are
the coordinates of the intersection? And then v is simply the angle, R
the radius of the circle?
Sounds reasonable to me...
>A combination of equations: cos(v)*R = Ax + (Dx)*t
> sin(v)*R = Ay + (Dy)*t
>
>I do this because the points of the line intersects on the circle-line
>which distance is R from origin. 'cos(v)*R' is the horizontal distance
>and sin(v)*R is the vertical distance. Hope you understand my thinking
>here. Only if could draw with a pen :).
Let's see. We are working on the plane. You are describing the circle
as being given by all points of the form (R*cos(v),R*sin(v)), as v
ranges over, say, 0 to 2pi.
You are describing the line as going through the points A=(a_1,a_2)
and B=(b_1,b_2), so you let D = B-A = (b_1-a_1,b_2-a_2) = (d_1,d_2), and the line
becomes
(x,y) = (a_1,a_2) + t(d_1,d_2)
where t ranges over all real numbers.
So any intersection between the circle and the line would have to
satisfy
a_1 + td_1 = R*cos(v)
a_2 + td_2 = R*sin(v)
for some value of t and some value of v.
>And no we do 'power of two' at both sides of equation.
You are squaring both equations... Okay...
HOWEVER: remember that because you squared the original equations, you
may have introduced new solutions that were not part of your original
intersections. For example, if you find a point where
R*(cos(v)) = - (a_1+td_1)
R*(sin(v)) = (a_2 + td_2)
then these values of v and t will ALSO satisfy
R^2*cos^2(v) = (a_1+td_1)^2
R^2*sin^2(v) = (a_2+td_2)^2
even though they do not satisfy the original equation.
In fact, the solutions to the following four systems:
ORIGINAL:
a_1 + td_1 = R*cos(v)
a_2 + td_2 = R*sin(v)
Plus
a_1 + td_1 = -R*cos(v)
a_2 + td_2 = R*sin(v)
a_1 + td_1 = R*cos(v)
a_2 + td_2 = -R*sin(v)
and
a_1 + td_1 = -R*cos(v)
a_2 + td_2 = -R*sin(v)
will also satisfy
(a_1 + td_1)^2 = R^2*cos^2(v)
(a_2 + td_2)^2 = R^2*sin^2(v)
So ->not every solution you find after squaring needs to be a solution
of your original equation<-. Every solution to your original equation
will also be a solution to the new one, but the new one may have more
solutions.
(It's like, if you start with x= 3, there is only one solution; but if
you square it, you get x^2 = 9, and now both x=3 and x=-3 are
solutions).
>This I do
>because
>of a forumla which I've to merge with this equation, see below.
>
> cos^2(v)*R^2 = (Ax + Dx*t)^2
>
> which also are
>
> ((Ax + Dx*t)^2)
> cos^2(v) = --------------------
> R^2
>
>
>
> sin^2(v)*R^2 = (Ay + Dy*t)^2
>
> which also are
>
> ((Ay + Dy*t)^2)
> sin^2(v) = --------------------
> R^2
Fine. Since
a_1 + td_1 = R*cos(v)
a_2 + td_2 = R*sin(v)
then cos(v) = (a_1 + t*d_1)/R
sin(v) = (a_2 + t*d_2)/R
>Ok now to the hard part.
>
>This is a math rule:
> sin^2(v) + cos^2(v) = 1
Identity. Yes.
>and this gives
> cos^2(v) = 1 - sin^2(v)
>
Yes.
>
>Now we combine the first combination with the formula above:
>
> ((Ax + Dx*t)^2)
> cos^2(v) = --------------------
> R^2
>
> will be
>
> ((Ax + Dx*t)^2)
> 1 - sin^2(v) = --------------------
> R^2
>
>
>And know we just take away the sin-function:
>
>
> ((Ay + Dy*t)^2) ((Ax + Dx*t)^2)
> 1 - -------------------- = --------------------
> R^2 R^2
Easier to just add the two equations you had:
From
a_1 + td_1 = R*cos(v)
a_2 + td_2 = R*sin(v)
we have
R^2 = R^2(cos^2(v) + sin^2(v) = (a_1+td_1)^2 + (a_2 + td_2)^2.
>Now I can get 't'. The equation will be, after some flipping and
>flopping of the variables, look like this:
>
>t^2*(Dx^2 + Dy^2) + t*(2*Ax*Dx + 2*Ay*Dy) - R^2 + Ay^2 + Ax^2 = 0
>
>If you don't see what this is I tell you this: ax^2 + bx + c = 0
>Now if you know what math is you know what it is.
>Now the question: "Why DOESN'T THIS WORK!!!" :|
Looks right.
What do you mean by "This does not work"?
Maybe you mean you sometimes get wrong answers? That's because of the
observation above. You have to make sure that whatever answers you get
actually satisfy the original equations. Plug them in. They should
work fine.
--
======================================================================
"It's not denial. I'm just very selective about
what I accept as reality."
--- Calvin ("Calvin and Hobbes")
======================================================================
Arturo Magidin
magidin@math.berkeley.edu
- Next message: tchow_at_lsa.umich.edu: "Re: Platonism"
- Previous message: W. Dale Hall: "Shiing-shen Chern (Chen Xingshen) passes away at 93"
- In reply to: Johannes Bergmark: "Circle-line intersection"
- Next in thread: Johannes Bergmark: "Re: Circle-line intersection"
- Reply: Johannes Bergmark: "Re: Circle-line intersection"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|