?? myline.java
字號:
import java.awt.geom.*;
public class MyLine {
public Point end1;
public Point end2;
public MyLine() {
//System.out.println("MyLine(){} Constructor!");
end1 = new Point();
end2 = new Point();
}
public MyLine(Point p1 , Point p2) {
end1 = new Point(p1);
end2 = new Point(p2);
}
public boolean Check(){
if (end1.Check())
{
if (end2.Check()) return true;
else return false;
}
else return false;
}
public double Length () {
double xLength;double yLength;
xLength = end2.GetX()-end1.GetX();
yLength = end2.GetY()-end1.GetY();
double value = Math.sqrt(xLength * xLength + yLength * yLength);
return value;
}
public double Distance(Point p) {
double x;double y;
x = p.GetX();y = p.GetY();
return Distance(x,y);
}
public double Distance(double x,double y){
Point C;
C = new Point(x,y);
MyLine AC;MyLine BC;
AC = new MyLine(end1,C);BC = new MyLine(end2,C);
double a;double b;double c;
a = BC.Length();b = AC.Length();c = Length();
double s;
s = (a + b + c)/2;
double area;
area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
double distance;
distance = area*2/Length();
return distance;
}
public boolean IsIntersectant (MyLine line2) {
if (Line2D.linesIntersect(end1.GetX(), end1.GetY(), end2.GetX(), end2.GetY(), line2.end1.GetX(), line2.end1.GetY(), line2.end2.GetX(), line2.end2.GetY())) return true;
else return false;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -