Circle-line intersection

From: Johannes Bergmark (johannes.bergmark_at_bredband.net)
Date: 12/03/04


Date: 3 Dec 2004 12:43:32 -0800

Hi there!
Don't tell me to look at other posts in this forum. This is a special
problem aimed to they who know math. The question how the get 't',
look below. I thought I solved the problem but the outcome was a
failure. I got a correct equation from mathworld but that is not what
I want though.

A line(L) intersects with a circle(C), tell me if something is wrong.
All positions orients from circle position which is (0,0).

t is what I want.
L = A + (B-A)*t
where D = B-A

Lx = cos(v)*R
Ly = sin(v)*R

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 origo. '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 :).

And no we do 'power of two' at both sides of equation. 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

Ok now to the hard part.

This is a math rule:
    sin^2(v) + cos^2(v) = 1
and this gives
    cos^2(v) = 1 - sin^2(v)

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

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!!!" :|

/Thank you for reading through, Johannes Bergmark



Relevant Pages

  • Re: Floating point questions
    ... In your particular case you're dealing in latitude and longitude, ... Somehow I have to believe the math needed to compute distance ... There was a time when I'd have been able to do the math. ...
    (comp.os.vms)
  • Re: Floating point questions
    ... In your particular case you're dealing in latitude and longitude, ... Somehow I have to believe the math needed to compute distance ... There was a time when I'd have been able to do the math. ...
    (comp.os.vms)
  • Re: Floating point questions
    ... In your particular case you're dealing in latitude and longitude, ... Somehow I have to believe the math needed to compute distance ... There was a time when I'd have been able to do the math. ...
    (comp.os.vms)
  • Re: Galilean transformation equations
    ... psychology of Robert Winn.- Hide quoted text - ... Isn't this enough mathematics for you, Robert? ... (distance in S')/ ... You've got the math. ...
    (sci.physics.relativity)
  • Re: Floating point questions
    ... Dave Froble writes: ... Source data is a GPS that provides litten endian IEEE 32 bit value. ... Somehow I have to believe the math needed to compute distance ... There was a time when I'd have been able to do the math. ...
    (comp.os.vms)