getAngle, getNewPoint
2014-02-14 17:20
351 查看
//求两个点的角度
float getAngle(CCPoint &a, CCPoint &b) { float x = b.x-a.x; float y = b.y-a.y; float hypotenuse = sqrt(pow(x, 2)+pow(y, 2)); //斜边长度 float cos = x/hypotenuse; float radian = acos(cos); //求出弧度 float angle = 180/(3.14159265359/radian); if (y<0) { angle = 180+angle; } else if ((y == 0) && (x<0)) { angle = 180; } return angle; }//获得点a到点b方向的fDistance像素的位置
CCPoint getNewPoint(CCPoint &a, CCPoint &b, float fDistance) { CCPoint c; //(b.y-a.y)/(c.y-a.y)=(ccpDistance(a,b)/fDistance); //(b.y-a.y)/(ccpDistance(a,b)/fDistance) = (c.y-a.y) c.x = (b.x-a.x)/(ccpDistance(a,b)/fDistance) + a.x; c.y = (b.y-a.y)/(ccpDistance(a,b)/fDistance) + a.y; return c; }
相关文章推荐
- ORACLE用户建表:ORA-01950: no privileges on tablespace 解决
- c++获取系统当前时间
- ORA-01652(永久表空间临时段不能扩展情况分析)
- 支持Android4.0以下webp的使用
- ARM软件优化,从1s到10ms
- js通过点击一个按钮跳转到一个查询页面--window.showModalDialog
- IMS 相关名词解释
- 露眼看App--怎样做一款旅游类的App ?
- 网页图标使用字体文件来定义
- 谈谈如何学习Linux内核 (二) —— 站在系统的角度去学习
- 对于android手机2px的解决方案
- 读写者的四种优先调度方式
- 只读事务的一些概念
- Unity3d策略模式
- FW: diff between =null and is NULL in sql
- 使用ajax上传/下载文件方法
- Necklace
- 几种web报表打印方案的比较
- CentOS6.5系统挂载NTFS分区的移动硬盘
- C# 服务端编程监听IP和端口号