卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章64334本站已运行4115

在C程序中,将以下内容翻译为中文:3D中两个平面的夹角

这里我们将看到如何计算三维空间中两个平面之间的角度。平面是 P1 和 P2。 Pi 的方程如下 -

在C程序中,将以下内容翻译为中文:3D中两个平面的夹角

在C程序中,将以下内容翻译为中文:3D中两个平面的夹角

示例

#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";
}

输出

Angle: 123.697 degree

卓越飞翔博客
上一篇: 如何在 C# 中验证电子邮件地址?
下一篇: C程序删除文件
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏