Class Vector2

java.lang.Object
  extended by Vector2

public class Vector2
extends java.lang.Object

This class contains methods to handle Vector2 objects.


Field Summary
 float x
           
 float y
           
 
Constructor Summary
Vector2()
          Constructor to create a Vector2.
Vector2(float x, float y)
          Constructor to create a Vector2.
Vector2(Vector2 v)
          Method to copy a Vector2 object.
Vector2(Vector4 v)
          Method to copy a the first 2 components of a Vector4 object to a Vector2 object.
 
Method Summary
 Vector2 add(Vector2 v)
          Method to add a Vector2 to an existing Vector2.
static Vector2 add(Vector2 v1, Vector2 v2)
          Static method to add two Vector2.
 float getLength()
          Method that returns the length of current Vector2.
static Vector2 getShortest(Vector2 v1, Vector2 v2)
          Returns the shortest of the two supplied vectors.
 Vector2 normalize()
          Method to normalize the current Vector2.
static float pixel2World(int pixel, Camera c)
          Method to convert a image coordinate (1D) to image coordinates.
static Vector2 project(Vector4 p, Camera c)
          Method to project a Vector4 onto an imageplane
 Vector2 sub(Vector2 v)
          Method to subtract a Vector2 from an current Vector2.
static Vector2 sub(Vector2 v1, Vector2 v2)
          Static method to subtract a Vector2 from another
static int world2Pixel(float world, Camera c)
          Method to convert a world position (1D) to image coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public float x

y

public float y
Constructor Detail

Vector2

public Vector2()
Constructor to create a Vector2.


Vector2

public Vector2(float x,
               float y)
Constructor to create a Vector2.

Parameters:
x - the x value.
y - the y value.

Vector2

public Vector2(Vector2 v)
Method to copy a Vector2 object.

Parameters:
v - the Vector2 that should be copied.

Vector2

public Vector2(Vector4 v)
Method to copy a the first 2 components of a Vector4 object to a Vector2 object.

Parameters:
v - the Vector4 of which the first 2 component shall be copied.
Method Detail

add

public static Vector2 add(Vector2 v1,
                          Vector2 v2)
Static method to add two Vector2.

Parameters:
v1 - a Vector2.
v2 - a Vector2.
Returns:
A new Vector2.

add

public Vector2 add(Vector2 v)
Method to add a Vector2 to an existing Vector2.

Parameters:
v - a Vector2.
Returns:
a Vector2.

sub

public static Vector2 sub(Vector2 v1,
                          Vector2 v2)
Static method to subtract a Vector2 from another

Parameters:
v1 - a Vector2
v2 - a Vector2 to subtract
Returns:
A new Vector2

sub

public Vector2 sub(Vector2 v)
Method to subtract a Vector2 from an current Vector2.

Parameters:
v - a Vector2 that should be subtracted.
Returns:
a Vector2.

getLength

public float getLength()
Method that returns the length of current Vector2.

Returns:
the length.

normalize

public Vector2 normalize()
Method to normalize the current Vector2.

Returns:
the normalized Vector2.

project

public static Vector2 project(Vector4 p,
                              Camera c)
Method to project a Vector4 onto an imageplane

Parameters:
c - the Camera containing the imageplane
p - the Vector4 to project
Returns:
the resulting Vector2

world2Pixel

public static int world2Pixel(float world,
                              Camera c)
Method to convert a world position (1D) to image coordinates.

Parameters:
c - the camera containing the image coordinates.
world - the point in the world.
Returns:
the converted point

pixel2World

public static float pixel2World(int pixel,
                                Camera c)
Method to convert a image coordinate (1D) to image coordinates.

Parameters:
c - the camera containing the image coordinates.
pixel - the point in the image (1D).
Returns:
the converted point

getShortest

public static Vector2 getShortest(Vector2 v1,
                                  Vector2 v2)
Returns the shortest of the two supplied vectors. If the vectors are of equal length, the second one is returned.

Parameters:
v1 - the first vector.
v2 - the second vector.
Returns:
the shortest of the two vectors or the second one if they are of equal length.