00001 package ImageStuff; 00002 00003 00004 public class Loc{ 00008 protected int x; 00009 00013 protected int y; 00014 public Loc(int x,int y) { 00015 this.x=x; 00016 this.y=y; 00017 } 00018 00023 public void setX(int x){ 00024 this.x=x; 00025 } 00026 00031 public void setY(int y){ 00032 this.y=y; 00033 } 00034 00039 public int getX(){ 00040 return x; 00041 } 00042 00047 public int getY(){ 00048 return y; 00049 } 00050 00051 public float norm(){ 00052 return (float)Math.sqrt(getX()*getX()+getY()*getY()); 00053 } 00054 public boolean isOn(Loc l){ 00055 return getX()==l.getX() && getY()==l.getY(); 00056 } 00057 00058 public Loc min(Loc l){ 00059 return new Loc(getX()-l.getX(),getY()-l.getY()); 00060 } 00061 00062 public float distance(Loc l){ 00063 return (float)(Math.sqrt( Math.pow(this.getX()-l.getX(),2) 00064 +Math.pow(this.getY()-l.getY(),2) 00065 )); 00066 } 00067 00068 public void print(){ 00069 Debug.print("Loc: (" + getX()+","+getY()+")"); 00070 } 00071 00072 00073 00074 } 00075
1.5.5