The only, at least a bit comprehensible explanation I managed to find, with almost ready scripts is Intersection of a Line and a Sphere (or circle). Although I can't figure out how exactly I have to use them ^^;.
I mean I tried, but the results are incredibly strange,if you want you can see the code:
Local x1:Float=100.0 Local y1:Float=100.0 Local x2:Float=500.0 Local y2:Float=200.0 Local x3:Float=400.0 Local y3:Float=400.0 Local rad:Float=25 Local a:Float=(x2-x1)^2+(y2-y1)^2 Local b:Float=2*((x2-x1)*(x1-x3)+(y2-y1)*(y1-y3)) Local c:Float=x3^2+y3^2+x1^2+y1^2-2*(x3*x1+y3*y1)-rad^2 Local delta:Float=b^2-4*a*c Local ix:Float=0.0 Local iy:Float=0.0 Local jx:Float=0.0 Local jy:Float=0.0 Local u1:Float=0.0 Local u2:Float=0.0 If delta>0 u1=(-b-Sqr(delta))/(2*a) u2=(-b+Sqr(delta))/(2*a) ix=x1+u1*(x2-x1) iy=y1+u1*(y2-y1) jx=x1+u2*(x2-x1) jy=y1+u2*(y2-y1) EndIfDoubt it will be helpful anyhow, but might it be you notice some mistake I did not noticed.
The numbers I get are extraordinarily large.
I compare what I have with what is written there. I noticed, that the first and only thing I can calculate is A,B and C. When I have those I can get to calculating Delta, and then get the two points of intersection with help of the almost first err... Code? The "P = P1 + u (P2 - P1)".
And when it comes to the fact, that I only want to check if the Circle intersects the line in between these two points, the stuff explained there gets completely incomprehensible -_-.
So, some little, or better, a lot of help would be nice to have :).
Thanks in Advance.
EDIT:Gaah, I just noticed what is wrong -_-. Wehan calculation U1 and U2 I forgot to put /2*a in parenthesis /(2*a) and now it works.
Still, this leaves me with no understanding to the second part indicating how to test if the intersection happens with the line segment...
EDIT2:The classical understandment after asking questions - I got it. I don't believe it myself, but I understood the problem, and fought it bravely! ^_^.
Sorry for posting this thread, but when I posted this, the info there was like an understandable nonsense, though after some break it became more understandable ^^;.
Anyhow, sorry for this.


Sign In
Create Account


Back to top









