cocoaTouch/otherSrc/CGPointUtils.c
author koda
Sat, 01 May 2010 12:53:55 +0000
changeset 3385 361bd29293f4
parent 2725 89908847b155
permissions -rw-r--r--
add automatic rotation in ipad (landscape only) possible fix for compiling hw under haiku restore randomity in choosing the theme
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2678
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     1
/*
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     2
 *  CGPointUtils.c
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     3
 *  PinchMe
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     4
 *
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     5
 *  Created by Jeff LaMarche on 8/2/08.
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     6
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     7
 *
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     8
 */
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
     9
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    10
#include "CGPointUtils.h"
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    11
#include <math.h>
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    12
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    13
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    14
CGFloat distanceBetweenPoints (CGPoint first, CGPoint second) {
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    15
	CGFloat deltaX = second.x - first.x;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    16
	CGFloat deltaY = second.y - first.y;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    17
	return sqrt(deltaX*deltaX + deltaY*deltaY );
2725
89908847b155 input handling reworked, still a lot of bugs in mouse movement
koda
parents: 2678
diff changeset
    18
}
2678
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    19
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    20
CGFloat angleBetweenPoints(CGPoint first, CGPoint second) {
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    21
	CGFloat height = second.y - first.y;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    22
	CGFloat width = first.x - second.x;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    23
	CGFloat rads = atan(height/width);
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    24
	return radiansToDegrees(rads);
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    25
}
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    26
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    27
CGFloat angleBetweenLines(CGPoint line1Start, CGPoint line1End, CGPoint line2Start, CGPoint line2End) {
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    28
	CGFloat a = line1End.x - line1Start.x;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    29
	CGFloat b = line1End.y - line1Start.y;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    30
	CGFloat c = line2End.x - line2Start.x;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    31
	CGFloat d = line2End.y - line2Start.y;
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    32
	CGFloat rads = acos(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    33
	return radiansToDegrees(rads);
334016e8d895 injection of custom code in SDL for iPhone in order to implement our frontend
koda
parents:
diff changeset
    34
}