Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fd07316

Browse files
author
linyiqun
committed
数据坐标点类
数据坐标点类
1 parent 3fc09c6 commit fd07316

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

‎Others/DataMining_KDTree/Point.java‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package DataMining_KDTree;
2+
3+
/**
4+
* 坐标点类
5+
*
6+
* @author lyq
7+
*
8+
*/
9+
public class Point{
10+
// 坐标点横坐标
11+
Double x;
12+
// 坐标点纵坐标
13+
Double y;
14+
15+
public Point(double x, double y){
16+
this.x = x;
17+
this.y = y;
18+
}
19+
20+
public Point(String x, String y) {
21+
this.x = (Double.parseDouble(x));
22+
this.y = (Double.parseDouble(y));
23+
}
24+
25+
/**
26+
* 计算当前点与制定点之间的欧式距离
27+
*
28+
* @param p
29+
* 待计算聚类的p点
30+
* @return
31+
*/
32+
public double ouDistance(Point p) {
33+
double distance = 0;
34+
35+
distance = (this.x - p.x) * (this.x - p.x) + (this.y - p.y)
36+
* (this.y - p.y);
37+
distance = Math.sqrt(distance);
38+
39+
return distance;
40+
}
41+
42+
/**
43+
* 判断2个坐标点是否为用个坐标点
44+
*
45+
* @param p
46+
* 待比较坐标点
47+
* @return
48+
*/
49+
public boolean isTheSame(Point p) {
50+
boolean isSamed = false;
51+
52+
if (this.x == p.x && this.y == p.y) {
53+
isSamed = true;
54+
}
55+
56+
return isSamed;
57+
}
58+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /