Linear Algebra and the C Language/a05y


The coefficients of the equation of a line.

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 line passing through points P and Q:
 
   c1 x  + c2 y  + c3 = 0

This same equation with the points P(x1,y1) Q(x2,y2):
 
   c1 x1 + c2 y1 + c3 = 0
   c1 x2 + c2 y2 + c3 = 0
 
The system of three equations:

   c1 x   + c2 y   + c3 = 0
   c1 x1 + c2 y1 + c3 = 0
   c1 x2 + c2 y2 + c3 = 0

The determinant of the system:

    |x    y   1| 
    |x1   y1  1| = 0
    |x2   y2  1| 

The determinant in C language:

    |1    1   1| 
    |x1   y1  1| = 0
    |x2   y2  1| 

To calculate the coefficients of the equation of the line, we use the cofactor expansion along the first row.
  
  cofactor_R(A,R1,C1) x + cofactor_R(A,R1,C2) y + cofactor_R(A,R1,C3) = 0

This equation gives us the equation of the line
that passes through the two points P and Q.

The application

Delete this h file at the end of the session.