zombie.iso
Class Vector3

java.lang.Object
  extended by zombie.iso.Vector3
All Implemented Interfaces:
java.lang.Cloneable

public class Vector3
extends java.lang.Object
implements java.lang.Cloneable

Author:
LEMMY

Field Summary
 float x
          The horizontal part of this vector
 float y
          The vertical part of this vector
 float z
           
 
Constructor Summary
Vector3()
          Create a new vector with zero length
Vector3(float x, float y, float z)
          Create a new vector with specified horizontal and vertical parts
Vector3(Vector3 other)
          Create a new vector which is identical to another vector
 
Method Summary
 Vector2 add(Vector2 other)
          Add another vector to this one and return as a new vector
 Vector3 addToThis(Vector2 other)
          Add another vector to this one and store the result in this one
 Vector3 aimAt(Vector2 other)
          Set the direction of this vector to point to another vector, maintaining the length
 float angleTo(Vector2 other)
          Calculate the angle between this point and another
 Vector3 clone()
          Clone this vector
 float distanceTo(Vector2 other)
          Calculate the distance between this point and another
static float dot(float x, float y, float tx, float ty)
           
 float dot(Vector2 other)
           
 boolean equals(java.lang.Object other)
          See if this vector is equal to another
static Vector2 fromAwtPoint(java.awt.Point p)
          Create a new vector from an AWT Point
static Vector2 fromLengthDirection(float length, float direction)
          Create a new vector with a specified length and direction
 float getDirection()
          get the direction in which this vector is pointing
Note: if the length of this vector is 0, then the direction will also be 0
 float getLength()
          get the length of this vector
 void normalize()
           
 void rotate(float rad)
           
 Vector3 set(float x, float y, float z)
          Set the horizontal and vertical parts of this vector
 Vector3 set(Vector3 other)
          Make this vector identical to another vector
 Vector3 setDirection(float direction)
          Set the direction of this vector, maintaining the length
 Vector3 setLength(float length)
          Set the length of this vector, maintaining the direction
 Vector3 setLengthAndDirection(float direction, float length)
          Set the length and direction of this vector
 java.awt.Dimension toAwtDimension()
          Convert this vector to an AWT Dimension
 java.awt.Point toAwtPoint()
          Convert this vector to an AWT Point
 java.lang.String toString()
          Returns a string representing this vector
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public float x
The horizontal part of this vector


y

public float y
The vertical part of this vector


z

public float z
Constructor Detail

Vector3

public Vector3()
Create a new vector with zero length


Vector3

public Vector3(Vector3 other)
Create a new vector which is identical to another vector

Parameters:
other - The Vector2 to copy

Vector3

public Vector3(float x,
               float y,
               float z)
Create a new vector with specified horizontal and vertical parts

Parameters:
x - The horizontal part
y - The vertical part
Method Detail

rotate

public void rotate(float rad)

fromAwtPoint

public static Vector2 fromAwtPoint(java.awt.Point p)
Create a new vector from an AWT Point

Parameters:
p - The java.awt.Point to convert
Returns:
A new Vector2 representing the Point

fromLengthDirection

public static Vector2 fromLengthDirection(float length,
                                          float direction)
Create a new vector with a specified length and direction

Parameters:
direction - The direction of the new vector, in radians
length - The length of the new vector
Returns:

add

public Vector2 add(Vector2 other)
Add another vector to this one and return as a new vector

Parameters:
other - The other Vector2 to add to this one
Returns:
The result as new Vector2

addToThis

public Vector3 addToThis(Vector2 other)
Add another vector to this one and store the result in this one

Parameters:
other - The other Vector2 to add to this one
Returns:
This vector, with the other vector added

aimAt

public Vector3 aimAt(Vector2 other)
Set the direction of this vector to point to another vector, maintaining the length

Parameters:
other - The Vector2 to point this one at.

angleTo

public float angleTo(Vector2 other)
Calculate the angle between this point and another

Parameters:
other - The second point as vector
Returns:
The angle between them, in radians

clone

public Vector3 clone()
Clone this vector

Overrides:
clone in class java.lang.Object

distanceTo

public float distanceTo(Vector2 other)
Calculate the distance between this point and another

Parameters:
other - The second point as vector
Returns:
The distance between them

dot

public float dot(Vector2 other)

dot

public static float dot(float x,
                        float y,
                        float tx,
                        float ty)

equals

public boolean equals(java.lang.Object other)
See if this vector is equal to another

Overrides:
equals in class java.lang.Object
Parameters:
other - A Vector2 to compare this one to
Returns:
true if other is a Vector2 equal to this one

getDirection

public float getDirection()
get the direction in which this vector is pointing
Note: if the length of this vector is 0, then the direction will also be 0

Returns:
The direction in which this vector is pointing in radians

getLength

public float getLength()
get the length of this vector

Returns:
The length of this vector

normalize

public void normalize()

set

public Vector3 set(Vector3 other)
Make this vector identical to another vector

Parameters:
other - The Vector2 to copy

set

public Vector3 set(float x,
                   float y,
                   float z)
Set the horizontal and vertical parts of this vector

Parameters:
x - The horizontal part
y - The vertical part

setDirection

public Vector3 setDirection(float direction)
Set the direction of this vector, maintaining the length

Parameters:
direction - The new direction of this vector, in radians

setLength

public Vector3 setLength(float length)
Set the length of this vector, maintaining the direction

Parameters:
length - The length of this vector

setLengthAndDirection

public Vector3 setLengthAndDirection(float direction,
                                     float length)
Set the length and direction of this vector

Parameters:
direction - The direction of this vector, in radians
length - The length of this vector

toAwtDimension

public java.awt.Dimension toAwtDimension()
Convert this vector to an AWT Dimension

Returns:
a java.awt.Dimension

toAwtPoint

public java.awt.Point toAwtPoint()
Convert this vector to an AWT Point

Returns:
a java.awt.Point

toString

public java.lang.String toString()
Returns a string representing this vector

Overrides:
toString in class java.lang.Object
Returns:
A String representing this vector