//求两个点的角度
float getAngle(CCPoint &a, CCPoint &b)
{
float x = b.x-a.x;
float y = b.y-a.y;
float hypotenuse = sqrt(pow(x, 2)+pow(y, 2));
//斜边长度
float cos = x/hypotenuse;
float radian = acos(cos);
//求出弧度
float angle = 180/(3.14159265359/radian);
if (y<0) {
angle = 180+angle;
} else if ((y == 0) && (x<0)) {
angle = 180;
}
return angle;
}
//获得点a到点b方向的fDistance像素的位置
CCPoint getNewPoint(CCPoint &a, CCPoint &b, float fDistance)
{
CCPoint c;
//(b.y-a.y)/(c.y-a.y)=(ccpDistance(a,b)/fDistance);
//(b.y-a.y)/(ccpDistance(a,b)/fDistance) = (c.y-a.y)
c.x = (b.x-a.x)/(ccpDistance(a,b)/fDistance) + a.x;
c.y = (b.y-a.y)/(ccpDistance(a,b)/fDistance) + a.y;
return c;
}