Linear Algebra and the C Language/a06c
The coefficients of the equation of a sphere.
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 sphere passing through points P, Q, R and S :
c1(x^2 +y^2 +z^2) +c2x +c3y +c4z +c5 = 0
This same equation with the points
P(x1,y1,z1) Q(x2,y2,z2) R(x3,y3,z3) and S(x4,y4,z4):
c1(x1^2+y1^2+z1^2)+c2x1+c3y1+c4z1+c5 = 0
c1(x2^2+y2^2+z2^2)+c2x2+c3y2+c4z2+c5 = 0
c1(x3^2+y3^2+z3^2)+c2x3+c3y3+c4z3+c5 = 0
c1(x4^2+y4^2+z4^2)+c2x4+c3y4+c4z4+c5 = 0
The system of five equations:
c1(x^2 +y^2 +z^2) +c2x +c3y +c4z +c5 = 0
c1(x1^2+y1^2+z1^2)+c2x1+c3y1+c4z1+c5 = 0
c1(x2^2+y2^2+z2^2)+c2x2+c3y2+c4z2+c5 = 0
c1(x3^2+y3^2+z3^2)+c2x3+c3y3+c4z3+c5 = 0
c1(x4^2+y4^2+z4^2)+c2x4+c3y4+c4z4+c5 = 0
The determinant of the system:
|(x ^2+y ^2+z ^2) x y z 1|
|(x1^2+y1^2+z1^2) x1 y1 z1 1|
|(x2^2+y2^2+z1^2) x2 y2 z2 1| = 0
|(x3^2+y3^2+z3^2) x3 y3 z3 1|
|(x4^2+y4^2+z4^2) x4 y4 z4 1|
The determinant in C language:
| 1 1 1 1 1|
|(x1^2+y1^2+z1^2) x1 y1 z1 1|
|(x2^2+y2^2+z1^2) x2 y2 z2 1| = 0
|(x3^2+y3^2+z3^2) x3 y3 z3 1|
|(x4^2+y4^2+z4^2) x4 y4 z4 1|
c1 (x^2 +y^2 +z^2) +
c2 x +
c3 y +
c4 z +
c5 = 0
To calculate the coefficients of the equation of the sphere,
we use the cofactor expansion along the first row.
cof(R1,C1) (x ^2+y ^2+z ^2)+
cof(R1,C2) x+
cof(R1,C3) y+
cof(R1,C4) z+
cof(R1,C5) = 0
This equation gives us the equation of the sphere
that passes through the four points P, Q, R and S.
Application
Delete this file at the end of the session.