Hmmm... I have a UITextView in the center of my app. I want to base the origin on that object.
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI)) - (CGFloat)angleFromPoints:(CGPoint)first second:(CGPoint)second { CGFloat height = second.y - first.y; CGFloat width = first.x - second.x; CGFloat rads = atan(height/width); return RADIANS_TO_DEGREES(rads); } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint origin = fullLabel.center; UITouch *touch = [touches anyObject]; CGPoint pt = [touch locationInView:self.view]; CGFloat angle = [self angleFromPoints:origin second:pt]; NSLog(@"%f", angle); } >From the top I get 90... around to the right side I get down to 0... then around from right to bottom -0 to -90 then around to left side 90 to 0 and then back to top from left side -0 to -90. ?? On Thu, Jan 5, 2012 at 2:02 PM, David Duncan <david.dun...@apple.com> wrote: > On Jan 5, 2012, at 10:49 AM, 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. > > > > Any pointers? Checking Google again. > > This is basically just the theta calculation of a convert to polar > coordinates. man atan2 should give you what you need to know. > -- > David Duncan > > _______________________________________________ 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