两条线之间的角度是错误的

两条线之间的角度是错误的

本文介绍了两条线之间的角度是错误的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want to get angles between two line.So I used this code.


int posX = (ScreenWidth) >> 1;

int posY = (ScreenHeight) >> 1;

double radians, degrees;

radians = atan2f( y - posY , x - posX);

degrees = -CC_RADIANS_TO_DEGREES(radians);

NSLog(@"%f %f",degrees,radians);


But it doesn't work .The Log is that: 146.309935 -2.553590

What's the matter?I can't know the reason.Please help me.

解决方案

If you simply use

radians = atan2f( y - posY , x - posX);

you'll get the angle with the horizontal line y=posY (blue angle).

You'll need to add M_PI_2 to your radians value to get the correct result.

这篇关于两条线之间的角度是错误的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 08:36