Ich muss den Winkel zwischen den Zeilen berechnen. Ich muss atan berechnen. Also habe ich einen solchen Code bin mitHilfe um atan2 richtig zu berechnen
static inline CGFloat angleBetweenLinesInRadians2(CGPoint line1Start, CGPoint line1End)
{
CGFloat dx = 0, dy = 0;
dx = line1End.x - line1Start.x;
dy = line1End.y - line1Start.y;
NSLog(@"\ndx = %f\ndy = %f", dx, dy);
CGFloat rads = fabs(atan2(dy, dx));
return rads;
}
Aber ich kann nicht über 180 Grad erhalten ((Nach 179 ° 178..160..150 gehen und so weiter.
muss ich auf 360 Grad drehen . Wie kann ich es tun Was ist los
maby das hilft:?
//Tells the receiver when one or more fingers associated with an event move within a view or window.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSArray *Touches = [touches allObjects];
UITouch *first = [Touches objectAtIndex:0];
CGPoint b = [first previousLocationInView:[self imgView]]; //prewious position
CGPoint c = [first locationInView:[self imgView]]; //current position
CGFloat rad1 = angleBetweenLinesInRadians2(center, b); //first angel
CGFloat rad2 = angleBetweenLinesInRadians2(center, c); //second angel
CGFloat radAngle = fabs(rad2 - rad1); //angel between two lines
if (tempCount <= gradus)
{
[imgView setTransform: CGAffineTransformRotate([imgView transform], radAngle)];
tempCount += radAngle;
}
}
Ich versuche es nicht funktionieren – yozhik
@yozhik: Vielleicht sollten Sie ex klar, was nicht funktioniert. Was ist das erwartete Ergebnis und was siehst du? – casablanca
Ich habe ein Dekart-Koordinatensystem. Auf dem ich Bild beziehe. Es gibt eine Imaging-Null. Wenn ich mein Bild in den oberen 180 Grad nehme und bewege - alles in Bewegung. Wenn ich versuche, Ander 180 Grad zu bewegen, zum Beispiel 190 - zeigt es mir 170 Grad. Ich brauche das dort wo 190 Grad sind. Sie sehen ... – yozhik