gpt4 book ai didi

java - 线(Vector3D,Vector3D)不工作

转载 作者:太空宇宙 更新时间:2023-11-04 12:09:13 25 4
gpt4 key购买 nike

我正在从一个点到另一个点画一条线,最终形成一个三角形。我正在使用appache.commons.math3。当我声明我按照文档页面所说的方式制作一行时,它说“找不到符号符号:方法 Line(org.apache.commons.math3,geometry.euclidean.third.Vector3D, org.apache.commons.math3,geometry.euclidean.third.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();
}
}
}

最佳答案

该行无效:

NewLine=线( t1, t2, 0.001);

快速猜测解决方案,尝试

NewLine=新线( t1, t2, 0.001);

“Line”是一种类型,而不是方法。

另外,newLine 和 lineOfIntercection 不应大写(标准命名约定)。

关于java - 线(Vector3D,Vector3D)不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40028129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com