forked from linyiqun/DataMiningAlgorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
59 lines (49 loc) · 932 Bytes
/
Point.java
File metadata and controls
59 lines (49 loc) · 932 Bytes
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
57
58
59
package DataMining_Chameleon;
/**
* 坐标点类
* @author lyq
*
*/
public class Point{
//坐标点id号,id号唯一
int id;
//坐标横坐标
Integer x;
//坐标纵坐标
Integer y;
//是否已经被访问过
boolean isVisited;
public Point(String id, String x, String y){
this.id = Integer.parseInt(id);
this.x = Integer.parseInt(x);
this.y = Integer.parseInt(y);
}
/**
* 计算当前点与制定点之间的欧式距离
*
* @param p
* 待计算聚类的p点
* @return
*/
public double ouDistance(Point p) {
double distance = 0;
distance = (this.x - p.x) * (this.x - p.x) + (this.y - p.y)
* (this.y - p.y);
distance = Math.sqrt(distance);
return distance;
}
/**
* 判断2个坐标点是否为用个坐标点
*
* @param p
* 待比较坐标点
* @return
*/
public boolean isTheSame(Point p) {
boolean isSamed = false;
if (this.x == p.x && this.y == p.y) {
isSamed = true;
}
return isSamed;
}
}