传进来的点,需要是莫卡托坐标
//点间距离
+(CGFloat)distanceBetweenPoints:(CGPoint)firstp second:(CGPoint)secondp
{
CGFloat deltaX = secondp.x - firstp.x;
CGFloat deltaY = secondp.y - firstp.y;
return sqrt(deltaX*deltaX + deltaY*deltaY );
}
//点间角度
+(CGFloat)angleBetweenPoints:(CGPoint)first second:(CGPoint)second
{
CGFloat height = second.y - first.y;
CGFloat width = first.x - second.x;
CGFloat rads = atan(height/width);
XMLog(@"%f",radiansToDegrees(rads));
return radiansToDegrees(rads);
}
//线间角度
//CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint line2End) {
//
// CGFloat a = line1End.x - line1Start.x;
// CGFloat b = line1End.y - line1Start.y;
// CGFloat c = line2End.x - line2Start.x;
// CGFloat d = line2End.y - line2Start.y;
//
// CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));
//
// return radiansToDegrees(rads);
//
//}