On 2012-01-05, at 1:49 PM, Eric E. Dolecki wrote: > I'd like to calculate the angle from a center point of a view to a touch > point. > > 0º behind top of screen, 180º being bottom of screen. > > Calculating from touchesMoved.
I think you can just retrieve the arctangent between the x axis and the vector formed by the origin and location of the touch (reversing the y coordinate). For example: - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint center = self.center; CGPoint location = [[touches anyObject] locationInView:self]; CGPoint vectorOfInterest = CGPointMake(location.x - center.x, center.y - location.y); NSLog(@"Vector: %@, Angle: %.2fº", NSStringFromCGPoint(vectorOfInterest), atan2(vectorOfInterest.x, vectorOfInterest.y) * 57.29); } The resulting angle will be [0, π) clockwise starting from the top, and [-π, 0) from the bottom (or something like that—my trig is horribly rusty). HTH, —Mt._______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com