Linear Algebra and the C Language/a06a


The coefficients of the equation of a circle.

Presentation :
 A homogeneous linear system with as many equations 
 as unknowns has a nontrivial  solution if and only 
 if the determinant  of the matrix is zero.
 
Let us calculate the equation of the circle passing through points P, Q and R :

  c1(x^2 +y^2)  + c2 x  + c3 y  + c4 = 0

 This same equation with the points P(x1,y1) Q(x2,y2) and R(x3,y3):

  c1(x1^2+y1^2) + c2 x1 + c3 y1 + c4 = 0
  c1(x2^2+y2^2) + c2 x2 + c3 y2 + c4 = 0
  c1(x3^2+y3^2) + c2 x3 + c3 y3 + c4 = 0
  

 The system of four equations:

  c1(x^2 +y^2)  + c2 x  + c3 y  + c4 = 0
  c1(x1^2+y1^2) + c2 x1 + c3 y1 + c4 = 0
  c1(x2^2+y2^2) + c2 x2 + c3 y2 + c4 = 0
  c1(x3^2+y3^2) + c2 x3 + c3 y3 + c4 = 0
 

  The determinant of the system:

    |x^2 + y^2  x      y      1|
    |x1^2+y1^2  x1     y1     1| = 0
    |x2^2+y2^2  x2     y2     1| 
    |x3^2+y3^2  x3     y3     1|
    
    
 The determinant in C language:

    |    1       1      1     1|
    |x1^2+y1^2  x1     y1     1| = 0
    |x2^2+y2^2  x2     y2     1| 
    |x3^2+y3^2  x3     y3     1|
    
To calculate the coefficients of the equation of the circle, 
we use the cofactor expansion along the first row.

  cof(R1,C1)(x^2 + y^2) + cof(R1,C2) x + cof(R1,C3) y + cof(R1,C4) = 0
  
This equation gives us the equation of the circle
that passes through the three points  P,  Q and R.

Application

Delete this file at the end of the session.