Created
February 6, 2013 08:32
-
-
Save C4Code/4721184 to your computer and use it in GitHub Desktop.
Arctangent example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// C4WorkSpace.m | |
// | |
// Created by Travis Kirton and Greg Debicki. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Shape *shape, *shape2; | |
} | |
-(void)setup { | |
shape = [C4Shape rect:CGRectMake(0, 0, 200, 10)]; | |
shape.anchorPoint = CGPointMake(0.0,0.5); | |
shape.center = self.canvas.center; | |
shape.userInteractionEnabled = NO; | |
[self.canvas addShape:shape]; | |
} | |
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { | |
CGPoint p = [[touches anyObject] locationInView:self.canvas]; | |
CGFloat arctangent = [C4Math atan2Y:p.y-self.canvas.center.y X:p.x-self.canvas.center.x]; | |
shape.rotation = arctangent; | |
event = event; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment