Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: how do i use point 3d?

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how do i use point 3d?

    i dont know whats wrong whith this code but it gives me some errors.

    the compiler says "cannot find symbol" on those lins:

    *13)point = new Point3D(x,y,z);
    *59)private java.lang.String toString()
    *5) Point3D point;

    public class Box3D extends java.lang.Object  {
     
       double width,length,height;
        Point3D point;
        //Constructor overloading:
        private  Box3D(double width, double length, double height)
        {
             this(0.0,0.0,0.0,width,length,height);
        }
        private  Box3D(double x, double y, double z, double width, double length,double height)
        {
            point = new Point3D(x,y,z);
     
            if (width <= 0) 
            {
                width = 1;
            }
            if (length <= 0)
            {
                length = 1;
            }
            if (height <= 0)
            {
                height = 1;
            }
            this.width = width;
            this.length = length;
            this.height = height;
        }
     
        //Methods:
        private  double getVolume()
        {    //Volume = (h)(w)(l)
            return (this.height * this.width * this.length);
        }
     
        private  boolean isInside(double pointX, double pointY, double pointZ)
        {
            //
            if(!pointX<=x){return false;}
            if(!pointT<=y){ return false;}
            if(!pointZ<=z){ return false;}
            else 
            {return true;}
        }
     
     private Point3D   getCenter() {  return ((this.height + this.width + this.length+this.x+this.y+this.z)/4);
     
        }
     
        private  void move(double dx, double dy, double dz)
        {
            //Moves the box by the given delta values.
            this.point.x += dx;
            this.point.y += dy;
            this.point.z += dz;
        }
        private  void scale(double factor)
        {
            //(Multiply all dimensions by
            //the specified factor).
            this.width *= factor;
            this.length *= factor;
            this.height *= factor;
        }
        private  java.lang.String toString()
        {
            //"(x, y, z)->(width, length, height)".
            return "("+this.point.x + ","+this.point.y + "," + this.point.z + ") -> " + "(" + width + "," + length + "," + height + ")";
        }}


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: how do i use point 3d?

    The compiler looks like it doesn't know what a Point3D is...so you probably need to define this class, either through your own implementation or via an import...
    If you wish to use the Vecmath Point3d object:
    import javax.vecmath.Point3d;
    //or more generally
    import javax.vecmath.*;

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how do i use point 3d?

    it says the package dosnt exist

    and know i have a new one:

    in this line it says "invalid method declaration;return type required"

    public class Point3D {
     
        private  int x;
        private  int y;
     
         public Point(int x, int y,int z) {
            this.x = x;
            this.y = y;
         this.z = z;
        }
     
        public int getX() {
            return x;
        }
     
        public int getY() {
            return y;
        }
     
          public int setY(int y) {
            return this.y=y;
        }
           public int setX(int x) {
            return this. x=x;
        }
         public int setX(int z) {
            return this. z=z;
        }
     public boolean equals(Object other) {
        boolean result = false;
        if (other instanceof Point) {
            Point that = (Point) other;
            result = (this.getX() == that.getX() && this.getY() == that.getY()&& this.getz() == that.getz()));
        }
        return result;
    }
     
     
    }
    Last edited by antrax; January 6th, 2010 at 04:10 PM.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: how do i use point 3d?

    So you wrote your own class, in which case you need to import Point3D into Box3D, and doing so will depend upon your package structure/directory structure. Given you have no package declaration, Point3D and Box3D must be in the same directory, so you can

    import Point3D;

    in this line it says "invalid method declaration;return type required"
    I don't know what line you are referring, but I'll hazard a guess this error is due to the improper constructor:
     public Point[COLOR="Red"]3D[/COLOR](int x, int y,int z) {

Similar Threads

  1. How can i point the mouse over a html element within the web browser?
    By bobomonkey in forum Java Theory & Questions
    Replies: 2
    Last Post: October 18th, 2009, 12:37 PM