Methods Summary |
---|
public Coordinates | add(Coordinates other)
HeightCoordinatesImpl o = (HeightCoordinatesImpl) other;
return new HeightCoordinatesImpl(x+o.x,y+o.y,Math.abs(h+o.h));
|
public boolean | atOrigin()
return( x==0&&y==0);
|
public float | distance(Coordinates other)
return this.sub(other).measure();
|
public boolean | equals(java.lang.Object arg0)
if(arg0 instanceof HeightCoordinatesImpl) {
HeightCoordinatesImpl other = (HeightCoordinatesImpl) arg0;
if(other.x != x || other.y != y || other.h != h) return false;
return true;
}
return false;
|
public float | getH()
return h;
|
public float | getX()
return x;
|
public float | getY()
return y;
|
public boolean | isValid()
return( valid(x) && valid(y) && valid(h) && Math.abs(x) <= MAX_X && Math.abs(y) <= MAX_Y && Math.abs(h) <= MAX_H);
|
public float | measure()
return (float) (Math.sqrt(x * x + y * y) + h);
|
public Coordinates | scale(float scale)
return new HeightCoordinatesImpl(scale * x,scale * y ,scale * h);
|
public Coordinates | sub(Coordinates other)
HeightCoordinatesImpl o = (HeightCoordinatesImpl) other;
return new HeightCoordinatesImpl(x-o.x,y-o.y,Math.abs(h+o.h));
|
public java.lang.String | toString()
return (int)x + "," + (int)y + "," + (int)h;
|
public Coordinates | unity()
float measure = this.measure();
if(measure == 0) {
//Special Vivaldi Case, when u(0) = random unity vector
float x = (float)Math.random();
float y = (float)Math.random();
float h = (float)Math.random();
return new HeightCoordinatesImpl(x,y,h).unity();
}
return this.scale(1/measure);
|
private boolean | valid(float f)
return( !(Float.isInfinite( f ) || Float.isNaN( f )));
|