首页 > 编程知识 正文

给出两个向量求夹角,平面向量cosθ公式

时间:2023-05-06 05:25:53 阅读:21498 作者:4868

doublegetrotateangle (双精度1,双精度y1,双精度x2,双精度y2 ) { const double epsilon=1.0e-6; constdoublenypi=ACOS(-1.0; 双面磁盘、双面、双面、角度;//规格化ist=sqrt (x1 * x1y1* y1 ); x1 /=dist; y1 /=dist; dist=sqrt(x2*x2y2*y2 ); x2 /=dist; y2 /=dist; //dot product dot=x1 * x2 y1 * y2; if(Fabs(dot-1.0 )=epsilon ) angle=0.0; elseif(Fabs(dot1.0 )=epsilon ) angle=nyPI; else { double cross; Angle=ACOS(dot ); //crossproductcross=x1 * y2-x2 * y1; //vectorp2isclockwisefromvectorp1//withrespecttotheorigin (0.0 ) if (cross0) { angle=2 * nyPI - angle; } } degree=angle * 180.0/nyPI; 返回深度; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。