记录下-两点角度计算
2017-08-07 16:50
232 查看
public static double GetAngle(double sx, double sy, double ex, double ey)
{
//两点的x、y值
var x = ex - sx;
var y = ey - sy;
//斜边长度
var len = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
if (len == 0) return 0; //2点重合
var cos = x / len;
//求出弧度
var radius = Math.Acos(cos);
//求角度
var angle = 180 / (Math.PI / radius);
if (y < 0)
{
angle = 360 - angle;
}
return Math.Round(angle); //取整
}
{
//两点的x、y值
var x = ex - sx;
var y = ey - sy;
//斜边长度
var len = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
if (len == 0) return 0; //2点重合
var cos = x / len;
//求出弧度
var radius = Math.Acos(cos);
//求角度
var angle = 180 / (Math.PI / radius);
if (y < 0)
{
angle = 360 - angle;
}
return Math.Round(angle); //取整
}
相关文章推荐
- 根据两点经纬度计算距离和角度——java实现
- (转)c# math 计算两点之间的角度公式
- 根据两点经纬度计算距离和角度——java实现
- 计算两点之间的距离,两点之间的斜率(角度)--秀清
- unity 计算两点的的角度
- [转]计算两点间的角度
- 两点计算角度
- 实用小程序记录1-计算地球两点之间的距离
- 记录两个函数--1.计算某个经纬度的周围某段距离的正方形的四个点。2.根据两点间的经纬度计算距离
- 计算两点之间的角度的代码
- unity 计算两点角度
- 通过两点坐标计算角度
- 同一坐标系中,由任意两点计算地图旋转角度
- 两点计算角度
- iOS 计算两点距离、点间角度、线间角度
- android 实现计算百度地图两点之间旋转角度,多点有向连接
- Calculate distance, bearing and more between Latitude/Longitude points——根据两点经纬度计算距离,角度及其他
- git是一种分布式代码管理工具,git通过树的形式记录文件的更改历史,比如: base'<--base<--A<--A' ^ | --- B<--B' 小米工程师常常需要寻找两个分支最近的分割点,即base.假设git 树是多叉树,请实现一个算法,计算git树上任意两点的最近分割点。 (假设git树节点数为n,用邻接矩阵的形式表示git树:字符串数组matrix包含n个字符串,每个字符串由字符'0
- 2001 计算两点间的距离
- 5-3 两点间距离计算