hamodeyks's blog

By hamodeyks, history, 2 years ago, In English

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

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it +7 Vote: I do not like it

Can you draw triangle with these 3 points?If yes, then I think you can draw a circle too

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    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).

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    if you can show a code that dose that I would apricate it

    • »
      »
      »
      2 years ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it
       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

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Instead, we can just check if the lines made by the points have the same slope and this is easier than area calculation.