### hamodeyks's blog

By hamodeyks, history, 6 weeks ago,

given three points like (1,1),(2,3),(3,6),I want to check if we can draw a circle that goes through all the points , Hope someone can help

• -3

 » 6 weeks ago, # |   +7 Can you draw triangle with these 3 points?If yes, then I think you can draw a circle too
•  » » 6 weeks ago, # ^ |   +1 You are right. You can always draw a circle through a triangle's points (supposing the points are not collinear); to be more precise, this circle is called the triangle's circumscribed circle (easy proof).
•  » » » 6 weeks ago, # ^ |   +6 yes I thought that way
 » 6 weeks ago, # |   0 You just need to check whether these points are collinear or not. If they are collinear then the given points lie on a straight line. Otherwise you can always draw a circle such that all three points will lie on circle.
•  » » 6 weeks ago, # ^ |   0 if you can show a code that dose that I would apricate it
•  » » » 6 weeks ago, # ^ | ← Rev. 3 →   0  int x1, y1, x2, y2, x3, y3; //points are (x1,y1),(x2,y2),(x3,y3) cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; int area = abs(x1 *(y2 - y3) + x2 *(y3 - y1) + x3 *(y1 - y2))/2; if (area == 0) { cout << "NO CIRCLE EXIST"; } use this formula to calculate the area of a triangle when coordinates are given
•  » » » » 6 weeks ago, # ^ |   0 I think formula should be 0.5*abs[(x1 * (y2 — y3) — x2 * (y1 — y3) + x3 * (y1 — y2)].You have taken abs difference of (y2, y3), (y3, y1), (y1, y2) which will give wrong answer in case of (1, 4), (1, 7) & (1, 4).These points are collinear.
•  » » » » » 6 weeks ago, # ^ |   0 Yes,I accidentally take mod of all terms.Now It's correct
•  » » » » 6 weeks ago, # ^ |   0 Instead, we can just check if the lines made by the points have the same slope and this is easier than area calculation.
 » 6 weeks ago, # |   0 If given 3 points are non-colinear(All of them don't lie on a single straight line) then there always exist a circle passing those 3 points. And to check if points are colinear or not you can find area of the triangle using these points and check if it's 0 or not. If it's 0 then the points are colinear
 » 6 weeks ago, # | ← Rev. 3 →   0 you have 3 points (x1, y1), (x2, y2), (x3, y3) and you need to find a point (center of circle) because if all three points lie on circle, the distance from center to them will be equal for all points. so, let's say the center of circle is (x, y) then you just need to solve below two equations. (x — x1)^2 + (y — y1)^2 = (x — x2)^2 + (y — y2)^2, (x — x1)^2 + (y — y1)^2 = (x — x3)^3 + (y — y3)^2
 » 6 weeks ago, # |   0 f(x)=x*(x+1) / 2
 » 6 weeks ago, # | ← Rev. 2 →   0 thanks for everyone who helped me