摘要:
最近在项目中需要判断点和四边形关系,我的算法中涉及到了求解线段夹角的问题,于是编写了如下代码。问题描述平面坐标系中,已知三点坐标,求出任意两点组成的线段之间的夹角。使用向量夹角公式cos<夹角> = 两向量之积 / 两向量模的乘积<夹角> = arccos( 两向量之积 / 两向量模的乘积 ) 1 #include <cmath> 2 using std::acos; // 反余弦函数 3 using std::sqrt; // 平方根函数 4 //------------------------------------------------------- 阅读全文