摘要: 向量夹角公式: cosα = A*B / (|A|*|B|) 设A(x1,y1),B(x2,y2); cosα =(x1*x2 + y1*y2) / sqrt( (x1^2 + y1^2) * (x2^2 + y2^2) )代码实现(c++):#include <math.h> //Calcucate angle between vector A and B//返回角度; return degreeint CalculateVectorAngle(int x1, int y1, int x2, int y2){ //acos return radian,we should tran 阅读全文
posted @ 2011-05-27 23:33 LittleAnt 阅读(10246) 评论(2) 推荐(0) 编辑
摘要: 1,判断两矩形区域是否相交不考虑矩形是斜的情况,但是看别人写的代码都比较复杂,所以不敢肯定百分之百正确,有认为是错误的请留言,多谢!代码实现(c++)struct RECT{ int left; int top; int right; int bottom;};//judge whether two rects intersectbool IsIntersect(RECT &rect1, RECT &rect2){ return !(rect1.left > rect2.right || rect2.left > rect1.right || \ rect1.top 阅读全文
posted @ 2011-05-27 23:32 LittleAnt 阅读(1515) 评论(0) 推荐(0) 编辑