# 已知6点，求两平面夹角

355人阅读 评论(0)
double fcos(double x1,double y1,double z1,double x2,double y2,double z2,double x3,double y3,double z3,
double x11,double y11,double z11,double x22,double y22,double z22,double x33,double y33,double z33){
double vect1[3],vect2[3],nomal1[3],nomal2[3];
vect1[0] = x2 - x1;vect1[1] = y2 - y1;vect1[2] = z2 - z1;
vect2[0] = x3 - x1;vect2[1] = y3 - y1;vect2[2] = z3 - z1;
//平面一法线
nomal1[0] = vect1[1]*vect2[2] - vect1[2]*vect2[1];
nomal1[1] = vect1[2]*vect2[0] - vect1[0]*vect2[2];
nomal1[2] = vect1[0]*vect2[1] - vect1[1]*vect2[0];

vect1[0] = x22 - x11;vect1[1] = y22 - y11;vect1[2] = z22 - z11;
vect2[0] = x33 - x11;vect2[1] = y33 - y11;vect2[2] = z33 - z11;
//平面二法线
nomal2[0] = vect1[1]*vect2[2] - vect1[2]*vect2[1];
nomal2[1] = vect1[2]*vect2[0] - vect1[0]*vect2[2];
nomal2[2] = vect1[0]*vect2[1] - vect1[1]*vect2[0];
//返回cos
return(-1 * fabs(nomal1[0]*nomal2[0]+nomal1[1]*nomal2[1]+nomal1[2]*nomal2[2])
/(sqrt(SQR(nomal1[0])+SQR(nomal1[1])+SQR(nomal1[2]))*sqrt(SQR(nomal2[0])+SQR(nomal2[1])+SQR(nomal2[2]))));
0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：14036次
• 积分：260
• 等级：
• 排名：千里之外
• 原创：11篇
• 转载：5篇
• 译文：0篇
• 评论：9条
最新评论