?? datapoint.java
字號(hào):
package cluster.kmeans;
/**
This class represents a candidate for Cluster analysis. A candidate must have
a name and two independent variables on the basis of which it is to be clustered.
A Data Point must have two variables and a name. A Vector of Data Point object
is fed into the constructor of the JCA class. JCA and DataPoint are the only
classes which may be available from other packages.
@author Shyam Sivaraman
@version 1.0
@see JCA
@see Cluster
*/
public class DataPoint {
private double mX,mY;
private String mObjName;
private Cluster mCluster;
private double mEuDt;
public DataPoint(double x, double y, String name) {
this.mX = x;
this.mY = y;
this.mObjName = name;
this.mCluster = null;
}
public void setCluster(Cluster cluster) {
this.mCluster = cluster;
calcEuclideanDistance();
}
public void calcEuclideanDistance() {
//called when DP is added to a cluster or when a Centroid is recalculated.
mEuDt = Math.sqrt(Math.pow((mX - mCluster.getCentroid().getCx()),
2) + Math.pow((mY - mCluster.getCentroid().getCy()), 2));//Math.pow(double a, double b) 是求a的b次方的
}
public double testEuclideanDistance(Centroid c) {
return Math.sqrt(Math.pow((mX - c.getCx()), 2) + Math.pow((mY - c.getCy()), 2));
}
public double getX() {
return mX;
}
public double getY() {
return mY;
}
public Cluster getCluster() {
return mCluster;
}
public double getCurrentEuDt() {
return mEuDt;
}
public String getObjName() {
return mObjName;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -