project_files/HedgewarsMobile/Classes/CGPointUtils.c
changeset 4476 4bf74e158f44
parent 3922 44804043b691
child 4976 088d40d8aba2
equal deleted inserted replaced
4474:499748f6e80f 4476:4bf74e158f44
    30     CGFloat c = line2End.x - line2Start.x;
    30     CGFloat c = line2End.x - line2Start.x;
    31     CGFloat d = line2End.y - line2Start.y;
    31     CGFloat d = line2End.y - line2Start.y;
    32     CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));
    32     CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));
    33     return radiansToDegrees(rads);
    33     return radiansToDegrees(rads);
    34 }
    34 }
       
    35 
       
    36 CGFloat CGPointDot(CGPoint a,CGPoint b) {
       
    37     return a.x*b.x+a.y*b.y;
       
    38 }
       
    39 
       
    40 CGFloat CGPointLen(CGPoint a) {
       
    41     return sqrtf(a.x*a.x+a.y*a.y);
       
    42 }
       
    43 
       
    44 CGPoint CGPointSub(CGPoint a,CGPoint b) {
       
    45     CGPoint c = {a.x-b.x,a.y-b.y};
       
    46     return c;
       
    47 }
       
    48 
       
    49 CGFloat CGPointDist(CGPoint a,CGPoint b) {
       
    50     CGPoint c = CGPointSub(a,b);
       
    51     return CGPointLen(c);
       
    52 }
       
    53 
       
    54 CGPoint CGPointNorm(CGPoint a) {
       
    55     CGFloat m = sqrtf(a.x*a.x+a.y*a.y);
       
    56     CGPoint c;
       
    57     c.x = a.x/m;
       
    58     c.y = a.y/m;
       
    59     return c;
       
    60 }