# how do i use point 3d?

• January 6th, 2010, 12:21 PM
antrax
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;

Code :

```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 + ")"; }}```
• January 6th, 2010, 01:11 PM
copeg
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:
Code :

```import javax.vecmath.Point3d; //or more generally import javax.vecmath.*;```
• January 6th, 2010, 02:52 PM
antrax
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"

Code :

```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; }     }```
• January 6th, 2010, 04:13 PM
copeg
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

Code :

`import Point3D;`

Quote:

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:
Code :

` public Point[COLOR="Red"]3D[/COLOR](int x, int y,int z) {`