Search code examples
javaapachelines

Line(Vector3D, Vector3D) not working


I am making a line from one point to another to eventually make a triangle. I am using appache.commons.math3. When i declare that im making a line in the way that the documentation pages say, it says "cannot find symbol symbol: method Line(org.apache.commons.math3,geometry.euclidean.threed.Vector3D, org.apache.commons.math3,geometry.euclidean.threed.Vector3D, double)

here is my code:

/*
 * 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();
        }
    }
}

Solution

  • This line is not valid:

    NewLine=Line( t1, t2, 0.001);

    Quick guess for a resolution, try

    NewLine=new Line( t1, t2, 0.001);

    "Line" is a type, not a method.

    Also newLine and lineOfIntercection should not be captialized (standard naming conventions).