我正在从一个点到另一个点制作一条线,最终形成一个三角形。我正在使用appache.commons.math3。当我声明我以文档页面所说的方式创建一行时,它表示"找不到符号 symbol:方法行(org.apache.commons.math3,geometry.euclidean.threed.Vector3D,org.apache.commons.math3,geometry.euclidean.threed.Vector3D,double)
这是我的代码:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.dis.test;
import java.util.ArrayList;
import org.apache.commons.math3.geometry.Point;
import org.apache.commons.math3.geometry.euclidean.threed.Euclidean3D;
import org.apache.commons.math3.geometry.euclidean.threed.Line;
import org.apache.commons.math3.geometry.euclidean.threed.Plane;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
/**
*
* @author hherzberg
*/
public class ThreeDTest {
private static Line LineOfIntercection;
private static Point<Euclidean3D> check;
private static double dist;
private static Line NewLine;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//setting up the points to make the first and second planes
Vector3D p1 = new Vector3D(0, 0, 0);
Vector3D p2 = new Vector3D(100, 0, 0);
Vector3D p3 = new Vector3D(0, 100, 0);
Vector3D n1 = new Vector3D(0, 0, 100);
Vector3D n2 = new Vector3D(100, 0, 0);
Vector3D n3 = new Vector3D(0, 0, 0);
Vector3D t1 = new Vector3D(0, 0, 100);
Vector3D t2 = new Vector3D(100, 0, 0);
Vector3D t3 = new Vector3D(0, 0, 0);
NewLine=Line( t1, t2, 0.001);
//point of intercection
//setting up a array that stores all the random points
//(doesnt do anything but its useful to store for perhaps later useage.
ArrayList<Vector3D> myPoints = new ArrayList<Vector3D>();
//creation of planes from the vector 3d points.
//4th number is the tolerance which we made pretty low because we deal with small numbers
Plane plane1 = new Plane(p1, p2, p3, 0.001);
Plane plane2 = new Plane(n1, n2, n3, 0.001);
//the line where plane one intersects with plane 2
LineOfIntercection = plane1.intersection(plane2);
System.out.println("the line of intercetion is: "+ LineOfIntercection.getDirection());
//try catch loop for the testing of random points distance to the plane
try {
for(int i=0; i<20; i++)
{
//the math.random makes a random number between 0 and 1, since i wanted a number between -100 and 100 i did this.
// in the future make variables so it doesent look so ugly
Vector3D NewPoint = new Vector3D( -100+(Math.random()*200) , -100+(Math.random()*200), -100+(Math.random()*200));
myPoints.add(NewPoint);
//this checks the distance from your point to a projection of the point onto the plane
//this should get the shortest distance from the point to the plane
check=plane2.project(NewPoint);
dist=check.distance(NewPoint);
System.out.println("the distance of point:" + i + " from plane 2 is: " + dist);
System.out.println(NewPoint);
System.out.println(check);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
答案 0 :(得分:0)
此行无效:
NewLine = Line(t1,t2,0.001);
快速猜测分辨率,尝试
NewLine = new Line(t1,t2,0.001);
“Line”是一种类型,而不是一种方法。
newLine和lineOfIntercection也不应该被限制(标准命名约定)。