相关疑难解决方法(0)

帮助正确计算atan2

我需要计算线之间的角度.我需要计算atan.所以我正在使用这样的代码

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;
}
Run Code Online (Sandbox Code Playgroud)

但是我不能超过180度((在179度之后178-160 ...... 150等等).

我需要旋转360度.我该怎么做?怎么了?

maby这有助于:

//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]; …
Run Code Online (Sandbox Code Playgroud)

objective-c image-rotation atan2

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

atan2 ×1

image-rotation ×1

objective-c ×1