00001 package ImageStuff.util;
00002
00003
00004
00005 public class Punt_3D {
00006
00010 protected float x;
00014 protected float y;
00018 protected float z;
00019 public Punt_3D(){
00020 setXYZ(0,0,0);
00021 }
00022
00023 public Punt_3D(float x,float y){
00024 setXYZ(x,y,0);
00025 }
00026
00027 public Punt_3D(float x, float y, float z) {
00028 setXYZ(x,y,z);
00029 }
00030
00031
00032 public void setXYZ(float x, float y, float z){
00033 setX(x);
00034 setY(y);
00035 setZ(z);
00036 }
00037
00038 public boolean liesOn(Punt_3D p){
00039 return p.getX_Int()==this.getX_Int() && p.getY_Int()== this.getY_Int();
00040 }
00041
00046 public void setX(float x){
00047 this.x=x;
00048 }
00049
00054 public void setY(float y){
00055 this.y=y;
00056 }
00057
00062 public void setZ(float z){
00063 this.z=z;
00064 }
00065
00070 public float getX(){
00071 return this.x;
00072 }
00073
00074 public int getX_Int(){
00075 return (int)(this.x);
00076 }
00077 public int getY_Int(){
00078 return (int)(this.y);
00079 }
00080
00085 public float getY(){
00086 return this.y;
00087 }
00088
00093 public float getZ(){
00094 return this.z;
00095 }
00096 public void print(){
00097 Debug.print(this.getX()+" " +this.getY() + " "+this.getZ());
00098 }
00099 public Punt_3D getcopy(){
00100 return new Punt_3D(this.getX(),this.getY(),this.getZ());
00101 }
00102
00103 public static Punt_3D add(Punt_3D p1, Punt_3D p2){
00104 return new Punt_3D(p1.getX()+p2.getX(),p1.getY()+p2.getY(),p1.getZ()+p2.getZ());
00105 }
00106
00107 public void add(myVector v){
00108 setX((float)(Math.round(getX()+v.getX())));
00109 setY((float)(Math.round(getY()+v.getY())));
00110 setZ(getZ()+v.getZ());
00111 }
00112
00113
00114 public static Punt_3D affieneComb(Punt_3D p1,float w1,Punt_3D p2,float w2){
00115 return new Punt_3D((float)(Math.round(p1.getX()*w1+p2.getX()*w2)),(float)(Math.round(p1.getY()*w1+p2.getY()*w2)),p1.getZ()*w1+p2.getZ()*w2);
00116 }
00117
00118
00119 }