iphone - Calculate angle for rotation in Pie Chart -


i want rotate image around center point.the problem facing need angle calculate in touch moved event (i dont want use multi touch).i current using below code

- (void)touchesmoved:(nsset *)touches withevent:(uievent *)event{  nsarray *alltouches = [touches allobjects];  gesturestartpoint = gesturemovedpoint;//i getting gesturestartpoint on touch began event  gesturemovedpoint = [[alltouches objectatindex:0] locationinview:[self superview]];  nslog(@"gesturemovedpoint = %@",nsstringfromcgpoint(gesturemovedpoint)); 

}

cgfloat previousangle = [self anglebetweenpoints:gesturestartpoint second11:gesturemovedpoint]; // atan2(gesturemovedpoint.y - gesturestartpoint.y, gesturemovedpoint.x - gesturestartpoint.x) * 180 / m_pi; cgfloat currentangle =atan2(self.transform.b, self.transform.a);//atan2(gesturemovedpoint.y - gesturestartpoint.y,gesturemovedpoint.x - gesturestartpoint.x) * 180 / m_pi;    cgfloat angletorotate = currentangle - previousangle;    float xpoint = (((atan2((gesturemovedpoint.x - gesturestartpoint.x) , (gesturemovedpoint.y - gesturestartpoint.y)))*180)/m_pi);      cgaffinetransform transform = cgaffinetransformmakerotation(angletorotate-100);    self.transform = transform; 

kindly me find solution stuck here , need complete application there dead line. in advance

glad remember triginometry

 -(void)degreestorotateobjectwithposition:(cgpoint)objpos andtouchpoint:(cgpoint)touchpoint{     float dx = touchpoint.x-objpos.x;        // distance along x    float dy = touchpoint.y-objpos.y;        // distance along y    float radians = atan2(dy, dx);          // tan = opp / adj     //now have convert radians degrees:    float degrees = radians*m_pi/360;     return degrees; } 

once have nice method, in touch event method. (i forgot it's called...)

cgaffinetransform current = view.transform;  [view settransform:cgaffinetransformrotate(current,
[self degreestorotateobjectwithposition:view.frame.origin
andtouchpoint:[touch locationinview:parentview]] //note: parentview = view object rotate sitting in.

this pretty code you'll need.the math right, i'm not sure settransform stuff. i'm @ school writing in browser. should able figure out here.

good luck,

aurum aquila


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -