이 튜토리얼에서는 3개의 점을 지나는 평면의 방정식을 찾는 프로그램에 대해 논의할 것입니다.
이를 위해 우리는 3 포인트를 제공받을 것입니다. 우리의 임무는 주어진 세 점으로 구성되거나 이를 통과하는 평면의 방정식을 찾는 것입니다.
예시
#include <bits/stdc++.h> #include<math.h> #include <iostream> #include <iomanip> using namespace std; //finding the equation of plane void equation_plane(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3){ float a1 = x2 - x1; float b1 = y2 - y1; float c1 = z2 - z1; float a2 = x3 - x1; float b2 = y3 - y1; float c2 = z3 - z1; float a = b1 * c2 - b2 * c1; float b = a2 * c1 - a1 * c2; float c = a1 * b2 - b1 * a2; float d = (- a * x1 - b * y1 - c * z1); std::cout << std::fixed; std::cout << std::setprecision(2); cout << "Equation of plane is " << a << " x + " << b << " y + " << c << " z + " << d << " = 0"; } int main(){ float x1 =-1; float y1 = 2; float z1 = 1; float x2 = 0; float y2 =-3; float z2 = 2; float x3 = 1; float y3 = 1; float z3 =-4; equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3); return 0; }
출력
Equation of plane is 26.00 x + 7.00 y + 9.00 z + 3.00 = 0