求两个向量夹角
2009-09-03 09:37
316 查看
/******************************************
输入:
3点坐标值
返回:
(first-cen)和(second-cen)两个向量的角度;
******************************************/
float CImageDoc::CalcAngle(CPoint cen,CPoint first,CPoint second)
{
float dx1,dx2,dy1,dy2;
float angle;
dx1 = first.x - cen.x;
dx2 = second.x - cen.x;
dy1 = first.y - cen.y;
dy2 = second.y - cen.y;
float c=(float)sqrt((dx1*dx1+dy1*dy1)*(dx2*dx2+dy2*dy2));
if(c==0) return -1;
angle = (float)asin((dx1*dy2-dy1*dx2)/c);
angle=angle*180/PI;
return angle;
}
输入:
3点坐标值
返回:
(first-cen)和(second-cen)两个向量的角度;
******************************************/
float CImageDoc::CalcAngle(CPoint cen,CPoint first,CPoint second)
{
float dx1,dx2,dy1,dy2;
float angle;
dx1 = first.x - cen.x;
dx2 = second.x - cen.x;
dy1 = first.y - cen.y;
dy2 = second.y - cen.y;
float c=(float)sqrt((dx1*dx1+dy1*dy1)*(dx2*dx2+dy2*dy2));
if(c==0) return -1;
angle = (float)asin((dx1*dy2-dy1*dx2)/c);
angle=angle*180/PI;
return angle;
}
相关文章推荐
- 判断两个向量之间夹角是逆时针或顺时针
- 解释脚本语言 计算两个向量的夹角度数。
- 用Python计算两个向量之间的夹角余弦值
- 两个向量夹角的cos值
- 基于MATLAB的线性代数 两个向量的夹角
- 点积应用-求两个向量夹角
- 点积应用-求两个向量夹角
- 分享:用Python计算两个向量之间的夹角余弦值
- [数学]已知两个向量,求夹角
- Unity 求两个向量间夹角
- 两个向量的夹角(顺时针)
- 两个单位向量的 夹角余弦 加上 欧式距离平方的一半 等于 1
- 如何计算两个向量的夹角
- C++ 实现两个向量之间的夹角
- 计算平面两个向量的夹角
- 通过矩阵求两个向量集中元素两两之间的欧氏距离(python实现)
- sklearn计算两个向量之间的距离
- 向量的叉乘即3D中任意两个三维向量的叉乘(向量积)推导及代码实现
- 判断两个向量是否平行
- python实现已知两个点坐标求与正北夹角度数