org.pzgui.math
Class Vector2i

java.lang.Object
  extended by org.pzgui.math.Vector2i
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Vector2i
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A 2-element vector that is represented by integers x,y coordinates.

Author:
David Underhill
See Also:
Serialized Form

Field Summary
 int x
           
 int y
           
 
Constructor Summary
Vector2i()
          Constructs and initializes a Vector3 to (0,0,0).
Vector2i(int[] v)
          Constructs and initializes a Vector2 from the array of length 3.
Vector2i(int x, int y)
          Constructs and initializes a Vector2 from the specified xy coordinates.
Vector2i(Vector2i v1)
          Constructs and initializes a Vector2 from the specified Vector3.
Vector2i(Vector2i from, Vector2i to)
          Constructs and initializes a Vector2 from one point to another
 
Method Summary
 Vector2i add(Vector2i v)
          adds v to this vector
static Vector2i add(Vector2i v1, Vector2i v2)
          adds v to this vector
 void clamp(int xMax, int yMax)
          clamps the values to the specified ranges (minimum value = 0)
 Vector2i clone()
           
 int getX()
           
 int getY()
           
 float length()
          Returns the length of this vector.
static Vector2i makeUnit(Vector2i v)
          adds v to this vector
 Vector2i multiply(int s)
          multiplies this by vec and returns this
static Vector2i multiply(Vector2i v1, int s)
          returns the product of a vector and a scalar
 void set(int x, int y)
          sets the components of this vector
 void set(Vector2i pos)
           
 void setX(int x)
           
 void setY(int y)
           
 Vector2i subtract(Vector2i v)
          subtracts v from this vector
static Vector2i subtract(Vector2i v1, Vector2i v2)
          adds v to this vector
 java.lang.String toString()
           
 java.lang.String toStringPlain()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y
Constructor Detail

Vector2i

public Vector2i(int x,
                int y)
Constructs and initializes a Vector2 from the specified xy coordinates.

Parameters:
x - the x coordinate
y - the y coordinate

Vector2i

public Vector2i(int[] v)
Constructs and initializes a Vector2 from the array of length 3.

Parameters:
v - the array of length 2 containing xyz in order

Vector2i

public Vector2i(Vector2i v1)
Constructs and initializes a Vector2 from the specified Vector3.

Parameters:
v1 - the Vector2 containing the initialization x y data

Vector2i

public Vector2i(Vector2i from,
                Vector2i to)
Constructs and initializes a Vector2 from one point to another


Vector2i

public Vector2i()
Constructs and initializes a Vector3 to (0,0,0).

Method Detail

getX

public int getX()

getY

public int getY()

set

public void set(Vector2i pos)

setX

public void setX(int x)

setY

public void setY(int y)

set

public void set(int x,
                int y)
sets the components of this vector


clamp

public void clamp(int xMax,
                  int yMax)
clamps the values to the specified ranges (minimum value = 0)


length

public final float length()
Returns the length of this vector.

Returns:
the length of this vector

add

public Vector2i add(Vector2i v)
adds v to this vector


subtract

public Vector2i subtract(Vector2i v)
subtracts v from this vector


multiply

public Vector2i multiply(int s)
multiplies this by vec and returns this


multiply

public static Vector2i multiply(Vector2i v1,
                                int s)
returns the product of a vector and a scalar


add

public static Vector2i add(Vector2i v1,
                           Vector2i v2)
adds v to this vector


subtract

public static Vector2i subtract(Vector2i v1,
                                Vector2i v2)
adds v to this vector


makeUnit

public static Vector2i makeUnit(Vector2i v)
adds v to this vector


clone

public Vector2i clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringPlain

public java.lang.String toStringPlain()