I'm doing a 3D flash game. I need to solve this algebraic problem before I can move forward. Can anyone help? I think I've got it right, but it just doesn't seem to produce the right co-ordinates in the game...<BR><BR>PROBLEM:<BR> Find the intercepts between a line and a circle.<BR> Line will always go through the centre point of the circle (a,b),<BR> so there will always be two intercepts.<BR><BR>KNOWN "GOOD" EQUATIONS:<BR> General equation of a line: y = mx + c<BR> General equation of a circle: r^2 = (x-a)^2 + (y-b)^2 (Where centre is at (a,b) and radius of r)<BR><BR>MY SOLUTION:<BR> If you feel brave, try it yourself, otherwise play spot the deliberate mistake:<BR> LET gen. equation of a line be #1.<BR> LET gen. equation of a circ be #2.<BR> REARRANGE #2:<BR> r^2 = (x - a)^2 + (y - b)^2<BR> (expand brackets)<BR> => r^2 = (x^2 - 2ax + a^2) + (y^2 - 2by + b^2)<BR> (re-arrange bits)<BR> => x^2 + y^2 - 2ax - 2by + a^2 + b^2 - r^2 = 0<BR> LET above equation be #3.<BR> As at intercepts, equations are equal:<BR> PLACE #1 into #3:<BR> => x^2 + (mx + c)^2 - 2ax - 2b(mx + c) + a^2 + b^2 - r^2 = 0<BR> (expand brackets again)<BR> => x^2 + ((mx)^2 + 2cmx + c^2) - 2ax - 2bmx - 2bc + a^2 + b^2 - r^2 = 0<BR> (group like terms)<BR> => x^2 + (mx)^2 + 2cmx - 2ax - 2bmx -2bc + a^2 + b^2 - r^2 + c^2 = 0<BR> LET above equation be #4<BR> Above equation is of the form Ax^2 + Bx + C = 0, therefore quadratic..<BR> Find values for A, B and C:<BR> A = (1 + m^2)<BR> B = (2cm - 2a - 2bm)<BR> C = (-2bc + a^2 + b^2 - r^2 + c^2)<BR> Quadratic equation formula states that:<BR> x = (-B +- sqrt(B^2 - 4AC)) / (2A)<BR> The DETERMINANT of a quadratic equation is given by:<BR> d = B^2 - 4AC<BR> If the determinant is less than zero, there are no roots to the equation in the real plane,<BR> (only complex roots). This should never be the case, because our line goes through the centre point.<BR> If the determinant equals zero, there is one real root (a tangent). This should never happen either.<BR> If the determinant is greater than zero, there are TWO real roots (one where the square root is positive,<BR> one where the square root is negative). This is what we're after.<BR> <BR> Now, this is fine. At this point, I've got an equation which I can use.<BR> When I code it into flash, though, I keep getting "no real roots" appear on screen, which is obviously wrong.<BR> I can't see where I've mis-typed the equation into Flash, so I figure it MUST be my maths...<BR><BR>Any ideas?<BR><BR>Craig.