#includeusingnamespacestd;classPlane{ private: doublea,b,c,d; public: &n"/> #includeusingnamespacestd;classPlane{ private: doublea,b,c,d; public: &n">

Home  >  Article  >  Backend Development  >  In a C program, translate the following into Chinese: The angle between two planes in 3D

In a C program, translate the following into Chinese: The angle between two planes in 3D

王林
王林forward
2023-08-25 16:41:10687browse

Here we will see how to calculate the angle between two planes in three-dimensional space. The planes are P1 and P2. The equation of Pi is as follows-

In a C program, translate the following into Chinese: The angle between two planes in 3D

If the angle is "A" then follow this rule-

In a C program, translate the following into Chinese: The angle between two planes in 3D

Example

#include <iostream>
#include <cmath>
using namespace std;
class Plane{
   private:
      double a, b, c, d;
   public:
      Plane(double a = 0, double b = 0, double c = 0, double d = 0){
         this->a = a;
         this->b = b;
         this->c = c;
         this->d = d;
      }
      double friend angle(Plane p1, Plane p2);
};
double angle(Plane p1, Plane p2){
   double nume = (p1.a * p2.a) + (p1.b * p2.b) + (p1.c * p2.c);
   double deno1 = (p1.a * p1.a) + (p1.b * p1.b) + (p1.c * p1.c);
   double deno2 = (p2.a * p2.a) + (p2.b * p2.b) + (p2.c * p2.c);
   return (180.0 / 3.14159) * acos(nume/ (sqrt(deno1) * sqrt(deno2)));
}
int main() {
   Plane p1(2.0, 2.0, -3.0, -5.0), p2(3.0, -3.0, 5.0, -6.0);
   cout << "Angle: " << angle(p1, p2) << " degree";
}

Output

Angle: 123.697 degree

The above is the detailed content of In a C program, translate the following into Chinese: The angle between two planes in 3D. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:C program to delete filesNext article:C program to delete files