data
Class Vector2

java.lang.Object
  extended by data.Vector2

public class Vector2
extends java.lang.Object

two dimensional float vector

Author:
Fennes

Field Summary
 float x
           
 float y
           
 
Constructor Summary
Vector2()
          x and y is set to 0
Vector2(float x, float y)
          vector constructor. sets x and y component to the given parameters
 
Method Summary
 Vector2 add(Vector2 other)
          adds this to other vector and stores result in this
 Vector2 clone()
          copies the value of this and returns a clone
 float distance(Vector2 other)
          calculates the distance between the two points specified by this vector and other
 float length()
          returns the length of the vector
 Vector2 mult(float scalar)
          multiplies this with scalar and stores result in this
 Vector2 normalize()
          normalizes this vector
 void set(float x, float y)
          sets x and y component to the given parameters
 Vector2 sub(Vector2 other)
           
 Vector2 subThisFrom(Vector2 other)
          subtracts this from other and stores result in this
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public float x

y

public float y
Constructor Detail

Vector2

public Vector2()
x and y is set to 0


Vector2

public Vector2(float x,
               float y)
vector constructor. sets x and y component to the given parameters

Parameters:
x - x
y - y
Method Detail

set

public void set(float x,
                float y)
sets x and y component to the given parameters

Parameters:
x - x
y - y

distance

public float distance(Vector2 other)
calculates the distance between the two points specified by this vector and other

Parameters:
other - other vector interpreted as point
Returns:
distance

normalize

public Vector2 normalize()
normalizes this vector

Returns:
this

length

public float length()
returns the length of the vector

Returns:
length

sub

public Vector2 sub(Vector2 other)

subThisFrom

public Vector2 subThisFrom(Vector2 other)
subtracts this from other and stores result in this

Parameters:
other - vector from which this is subtracted
Returns:
this

add

public Vector2 add(Vector2 other)
adds this to other vector and stores result in this

Parameters:
other - other vector that is added
Returns:
this

mult

public Vector2 mult(float scalar)
multiplies this with scalar and stores result in this

Parameters:
scalar -
Returns:
the vector = result

clone

public Vector2 clone()
copies the value of this and returns a clone

Overrides:
clone in class java.lang.Object