# Math Question

i am out of ideas; wikipedia could not help me, and so it is either a week with my nose in old math books or an embarassing question on the forums. (i choose you, pikachu!

please see attached picture; for a simple collision detection, i am trying to offset a circle (that intersects a line) out of the intersection (by moving him perpendicularly to the line). i’ve got all the formulas, but the math skills must have suffered from all the crayons up my nose.

(i came up with {CODE(ln=>0)}b = sqrt( r / m ^ 2 )+ 1 ±1)^, but it appears to be wrong.)

edit: i did not realize that
{CODE(ln=>0)}c^2 = r^2^ (instead of r)

the correct formula is {CODE(ln=>0)}sqrt r ^ 2 )/(( m ^ 2 )+ 1 /((-m-^-2-)±1)^

… i guess.

question.png (30.6 kB)

hi diki, as you are dealing with a circle, you just have to calculate the distance of the center to the line. then you subtract the distance from the radius to get the offset. then move the circle perpendicular to the line by that amount…
here is a good site, but google has lots more about point/line distance:
http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html

thanks tonfilm!