我试图找到Line2D
个对象的点,或者只是在它的交叉处回答。我现在得到的就是定义的行和代码的这一部分:
class Linia {
public java.awt.geom.Line2D.Double getLine() {
return line;
}
public void setLine(java.awt.geom.Line2D.Double line) {
this.line = line;
}
private java.awt.geom.Line2D.Double line;
}
public class Lines {
public static java.awt.geom.Line2D.Double create(double x1, double y1,double x2, double y2) {
java.awt.geom.Line2D.Double tmpL = new java.awt.geom.Line2D.Double();
tmpL.x1 = x1;
tmpL.y1 = y1;
tmpL.x2 = x2;
tmpL.y2 = y2;
return tmpL;
}
public int getIle() {
return ile;
}
public void setIle(int k) {
this.ile=ile;
}
private int ile;
public static void main(String[] args) {
int j, a = 0, z = 0, i, v = 0;
Scanner f = new Scanner(System.in);
j = f.nextInt();
double pktx[] = new double[j];
double pkty[] = new double[j];
Lines ile1 = new Lines();
ile1.setIle(Integer.valueOf(j));
for (i = 0; i < j; i++) {
Scanner h = new Scanner(System.in);
pktx[i] = h.nextInt();
Scanner o = new Scanner(System.in);
pkty[i] = o.nextInt();
}
for (i = j - 1; i > 0; i--) {
a=a+i;
}
Linia[] line = new Linia[a];
for (v = 0; v < a; v++) line[v]=new Linia();
v=0;
for (z = 0; z < j; z++) {
double d=pktx[z];
double y=pkty[z];
for (i = z + 1; i < j; i++) {
double u = pktx[i];
double t = pkty[i];
line[v].setLine(create(Double.valueOf(d), Double.valueOf(y), Double.valueOf(u), Double.valueOf(t)));
System.out.println("Linia " + v + " " + line[v].getLine().getBounds());
v++;
}
}
CTriangle count=new CTriangle();
count.linesIntersect(line[3], line[5]);
}
}
public class CTriangle {
public static boolean linesIntersect(Linia l1, Linia l2) {
System.out.println("Crossing");
return false;
}
}
对于积分1,1 4,1 4,4 1,4,似乎没有Crossing
,但确实如此。
我正在寻找显示üoint交点的方法,因为方法linesIntersection
正在返回false
或true
。或者正确实施方法linesintersection
。
答案 0 :(得分:0)
有人告诉我,我可以在linesIntersection方法中使用get行。也许有问题?或者更好地使用连接到类line2d的任何其他mothode来找到交叉点。