01.07.2013, 18:27
I think that:
Is the correct version.
Код:
stock LineIntersectCircle(Float:pA[2], Float:pB[2], Float:pC[2], Float:radius) { new Float: a = (pB[0]-pA[0])*(pB[0]-pA[0])+(pB[1]-pA[1])*(pB[1]-pA[1]); new Float: b = 2*((pB[0]-pA[0])*(pA[0]-pC[0])+(pB[1]-pA[1])*(pA[1]-pC[1])); new Float: c = pC[0]*pC[0]+pC[1]*pC[1]+pA[0]*pA[0]+pA[1]*pA[1]-2*(pC[0]*pA[0]+pC[1]*pA[1]) - radius*radius; new Float: konst = b*b-4*a*c; if(konst >= 0) { new Float: e = floatsqroot(konst); new Float: u1 = (-b+e)/(2*a); new Float: u2 = (-b-e)/(2*a); if(0 <= u1 <= 1 && 0 <= u2 <= 1) return 1; } return 0; }