Блог пользователя hamodeyks

Автор hamodeyks, история, 3 года назад, По-английски

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
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

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

»
3 года назад, # |
  Проголосовать: нравится 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.

  • »
    »
    3 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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

    • »
      »
      »
      3 года назад, # ^ |
      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

      • »
        »
        »
        »
        3 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

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