import java.lang.Math;
public class Point {
private double xaxis;
private double yaxis;
public static double doubleLimit=0.000000000000001;
public double getXaxis() {
return xaxis;
}
public void setXaxis(double xaxis) {
this.xaxis = xaxis;
}
public double getYaxis() {
return yaxis;
}
public void setYaxis(double yaxis) {
this.yaxis = yaxis;
}
public Point(double xaxis,double yaxis){
this.xaxis=xaxis;
this.yaxis=yaxis;
}
public boolean equals(Point anotherPoint){
if(xaxis==anotherPoint.getXaxis()&&yaxis==anotherPoint.getYaxis()){
return true;
}
return false;
}
public double getPointLength(Point otherPoint){
if(this.equals(otherPoint)){
return 0;
}else{
return Math.hypot(xaxis-otherPoint.getXaxis(),yaxis-otherPoint.getYaxis());
}
}
public boolean isOnLine(Line line){
if(this.equals(line.getFpoint())||this.equals(line.getSpoint())){
return true;
}
double length1=this.getPointLength(line.getFpoint());
double length2=this.getPointLength(line.getSpoint());
if(Math.abs(line.getLength()-length1-length2)<Point.doubleLimit){
return true;
}else{
评论8