project_files/HedgewarsMobile/Classes/CGPointUtils.c
changeset 4476 4bf74e158f44
parent 3922 44804043b691
child 4976 088d40d8aba2
--- a/project_files/HedgewarsMobile/Classes/CGPointUtils.c	Tue Dec 07 01:18:43 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/CGPointUtils.c	Wed Dec 08 14:47:52 2010 +0100
@@ -32,3 +32,29 @@
     CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));
     return radiansToDegrees(rads);
 }
+
+CGFloat CGPointDot(CGPoint a,CGPoint b) {
+    return a.x*b.x+a.y*b.y;
+}
+
+CGFloat CGPointLen(CGPoint a) {
+    return sqrtf(a.x*a.x+a.y*a.y);
+}
+
+CGPoint CGPointSub(CGPoint a,CGPoint b) {
+    CGPoint c = {a.x-b.x,a.y-b.y};
+    return c;
+}
+
+CGFloat CGPointDist(CGPoint a,CGPoint b) {
+    CGPoint c = CGPointSub(a,b);
+    return CGPointLen(c);
+}
+
+CGPoint CGPointNorm(CGPoint a) {
+    CGFloat m = sqrtf(a.x*a.x+a.y*a.y);
+    CGPoint c;
+    c.x = a.x/m;
+    c.y = a.y/m;
+    return c;
+}