2016-10-13 7 views
1

Я делаю линию из одной точки в другую, чтобы в итоге сделать треугольник. Я использую appache.commons.math3. Когда я объявляю, что im делает строку так, как говорят страницы документации, она говорит «не может найти символ символ: метод Line (org.apache.commons.math3, geometry.euclidean.threed.Vector3D, org.apache.commons .math3, geometry.euclidean.threed.Vector3D, двойной)Линия (Vector3D, Vector3D) не работает

вот мой код:

/* 
* 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

Эта линия не действует:

NewLine = Line (t1, t2, 0,001);

Быстро догадайтесь, разрешение

NewLine = новая линия (t1, t2, 0,001);

«Линия» - это тип, а не метод.

Кроме того, newLine и lineOfIntercection не должны быть запечатлены (стандартные соглашения об именах).

 Смежные вопросы

  • Нет связанных вопросов^_^