Necesito calcular el ángulo entre líneas. Necesito calcular atan. Así que estoy usando dicho códigoayuda para calcular atan2 correctamente
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;
}
Pero no puedo conseguir más de 180 grados ((Después de 179 grados va 178..160..150 y así sucesivamente.
necesito para girar en 360 grados . ¿Cómo puedo hacerlo ¿Qué pasa
maby esto ayuda:??
//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;
}
}
Lo intento. No trabajo – yozhik
@yozhik: Tal vez deberías ex claro lo que no funciona. ¿Cuál es el resultado esperado y qué estás viendo? – casablanca
Tengo un sistema de coordenadas decarta. En lo que estoy proctuando imagen. Hay imagen cero. Cuando tomo y muevo mi foto en los 180 grados superiores, todo al rededor. Cuando intento mover un ander 180 grados, por ejemplo 190, me muestra 170 grados. Necesito que haya 190 grados. Verá ... – yozhik