- #1
TOdorus
- 5
- 0
Hi all,
I have a bit of an algebraic problem, and my lack of attention during math is starting to show. I was experimenting with hit detection based on lines for a simple shooting game, and the enemies bieng circulair.
I already have a function to check the distance from the line to the circles centre, so I already know that there is a intersection (or hit). I also would like to know where it intersects, for graphics and some extra physics.
So here's what I got:
Known
r
m
b
so these can be considered constant
Equitions so far
y = mx+b
r^2 = y^2 + x^2
this gives:
r^2 = (mx+b)^2 + x^2
And then my troubles begin, because writing that out would give:
r^2 + b^2 = x^2 + mx^2 + 2mbx
Googling around tells me that this is the way to go, and you should get a quadratic function, but I don't know how to solve this kind of equation. Can anybody help out? I hope to finish a prototype soon.
Tnx in advance,
TO
I have a bit of an algebraic problem, and my lack of attention during math is starting to show. I was experimenting with hit detection based on lines for a simple shooting game, and the enemies bieng circulair.
I already have a function to check the distance from the line to the circles centre, so I already know that there is a intersection (or hit). I also would like to know where it intersects, for graphics and some extra physics.
So here's what I got:
Known
r
m
b
so these can be considered constant
Equitions so far
y = mx+b
r^2 = y^2 + x^2
this gives:
r^2 = (mx+b)^2 + x^2
And then my troubles begin, because writing that out would give:
r^2 + b^2 = x^2 + mx^2 + 2mbx
Googling around tells me that this is the way to go, and you should get a quadratic function, but I don't know how to solve this kind of equation. Can anybody help out? I hope to finish a prototype soon.
Tnx in advance,
TO