Vector3 structure
public class Vector3 {
public float x,y,z;
public Vector3() {
x = y = z = 0;
}
public Vector3(float x, float y, float z) {
super();
this.x = x;
this.y = y;
this.z = z;
}
public Vector3(double d, double e, double f) {
this.x = (float) d;
this.y = (float) e;
this.z = (float) f;
}
public float getX() {
return x;
}
public void setX(float x) {
this.x = x;
}
public float getY() {
return y;
}
public void setY(float y) {
this.y = y;
}
public float getZ() {
return z;
}
public void setZ(float z) {
this.z = z;
}
public Vector3 add(Vector3 b){
return new Vector3(x+b.x, y+b.y, z+b.z);
}
public Vector3 sub(Vector3 b){
return new Vector3(x+b.x, y+b.y, z+b.z);
}
public Vector3 mul(float b){
return new Vector3(x+b, y+b, z+b);
}
public Vector3 div(float b){
return new Vector3(x+b, y+b, z+b);
}
}
Related examples in the same category