-
Notifications
You must be signed in to change notification settings - Fork 803
/
AppCalculateMgr.java
56 lines (49 loc) · 1.05 KB
/
AppCalculateMgr.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.jingewenku.abrahamcaijin.commonutil;
/**
* 主要功能: 提供APP应用计算,算法等
*
* @Prject: CommonUtilLibrary
* @Package: com.jingewenku.abrahamcaijin.commonutil
* @author: AbrahamCaiJin
* @date: 2017年05月03日 16:37
* @Copyright: 个人版权所有
* @Company:
* @version: 1.0.0
*/
public class AppCalculateMgr {
/**
* 两点间的距离
* @param x1
* @param y1
* @param x2
* @param y2
* @return
*/
public static double distance(double x1,double y1,double x2,double y2)
{
return Math.sqrt(Math.abs(x1-x2)*Math.abs(x1-x2)+Math.abs(y1-y2)*Math.abs(y1-y2));
}
/**
* 计算点a(x,y)的角度
* @param x
* @param y
* @return
*/
public static double pointTotoDegrees(double x,double y)
{
return Math.toDegrees(Math.atan2(x,y));
}
/**
* 点在圆肉
* @param sx
* @param sy
* @param r
* @param x
* @param y
* @return
*/
public static boolean checkInRound(float sx, float sy, float r, float x, float y)
{
return Math.sqrt((sx - x) * (sx - x) + (sy - y) * (sy - y)) < r;
}
}