We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Sherlock and Geometry
Sherlock and Geometry
Sort by
recency
|
8 Discussions
|
Please Login in order to post a comment
This one was harder than I expected but I finally did it. * I calculated the distance from each point of the triangle to the circle center * if any of those distances equal the radius return "YES" * if all the distances were less than the circle radius then the triangle was inside and I returned "NO that was the easy part, then came the hard part created a function that returned true if any of the segments of a line interesect the circle. I had to use the quadratic equation for this one I had to calculate the A,B, and C of the quadratic equation. One of the variables used was the slope m of the line equation if the discriminat was less than zero, the segment doesn't touch and that function returned false if the discriminat was zero or more then it calculated the two solutions.
then with another function found out if those points lie within the segment.
That is, if that intersection was outside then there is no intersection. if any of those lines intresect, I return a "YES" so far so good. but it didn't work for all cases. then I remember that I have to take the special case when the line is vertical!!! So I added a condition for that, calculated the tww points if any, etc.... ...and after a lot of work, the damned thing worked!!!!
OwO
My approach is to calculate the power of the vertices with respect to circle.
If the points are inside print NO If 2 ouside 1 inside print YES If 1 ouside 2 inside print YES If any 1 is on the circle print YES
If all the points are outside then solve the equation with the circle and check if the root lies between the end points of the line segment. I am getting an error.
finally
this is my code which I wrote in 5-6 hours can someone point out what am i missing because this is really frustrating they have given a testcase and inside that testcase there are 30000 testcases :( instead they should have given 10 seprate testcases :(