Class Vector4

java.lang.Object
  extended by Vector4

public class Vector4
extends java.lang.Object

Class for handeling all vector computations


Field Summary
 float w
           
 float x
           
 float y
           
 float z
           
 
Constructor Summary
Vector4()
          Default constructor
Vector4(float x, float y, float z)
          Constructor
Vector4(float x, float y, float z, float w)
          Constructor
Vector4(Vector4 original)
          Copy constructor
 
Method Summary
 Vector4 add(Vector4 b)
          Adds a vector to current vector.
 Vector4 crossProduct(Vector4 o)
          Compute the cross product between two vectors
static Vector4 crossProduct(Vector4 n, Vector4 o)
          Compute the cross product between two vectors
 float dotProduct(Vector4 v)
          Compute the dot product of two vectors
 float getLength()
          Gets the length of a vector
 Vector4 negate()
          Negate a vector
static Vector4 negate(Vector4 v)
          Negate a vector
 Vector4 normalize()
          Normalize
 Vector4 normalize(Vector4 n)
          Normalize
 Vector4 pixel2world(Camera c)
          Convert image coordinates to world coordinates, no projection.
 Vector4 project(Camera c)
          Projects a point in world coordinates to the origin cameras viewplane.
 Vector4 project(Vector4 vect3D, Camera c)
          Projects a point in world coordinates to the origin cameras viewplane.
 void setVector4(float x, float y, float z, float w)
          Set new values to the vector
 Vector4 sub(Vector4 b)
          Subtracts a vector from current vector.
static Vector4 sub(Vector4 a, Vector4 b)
          Subtracts a vector from current vector.
 Vector4 world2pixel(Camera c)
          Convert world coordinates to image coordinates, no projection.
 
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

z

public float z

w

public float w
Constructor Detail

Vector4

public Vector4()
Default constructor


Vector4

public Vector4(float x,
               float y,
               float z,
               float w)
Constructor

Parameters:
x - The vectors x coeficient
y - The vectors y coeficient
z - The vectors z coeficient
w - The vectors w coeficient

Vector4

public Vector4(float x,
               float y,
               float z)
Constructor

Parameters:
x - The vectors x coeficient
y - The vectors y coeficient
z - The vectors z coeficient

Vector4

public Vector4(Vector4 original)
Copy constructor

Parameters:
original - The vector to be copied
Method Detail

setVector4

public void setVector4(float x,
                       float y,
                       float z,
                       float w)
Set new values to the vector

Parameters:
x - x-value
y - y-value
z - z-value
w - w-value

negate

public Vector4 negate()
Negate a vector


negate

public static Vector4 negate(Vector4 v)
Negate a vector

Parameters:
v - The vector to negate
Returns:
a new vector = - v

getLength

public float getLength()
Gets the length of a vector

Returns:
the lengt as a float

normalize

public Vector4 normalize()
Normalize

Returns:
the normalized vector

normalize

public Vector4 normalize(Vector4 n)
Normalize

Parameters:
n - The vector to normalize
Returns:
a new normalized vector

crossProduct

public static Vector4 crossProduct(Vector4 n,
                                   Vector4 o)
Compute the cross product between two vectors

Parameters:
n - The first vector
o - The second vector
Returns:
a new vector orthogonal to the others

crossProduct

public Vector4 crossProduct(Vector4 o)
Compute the cross product between two vectors

Parameters:
o - The second vector
Returns:
the resulting vector

dotProduct

public float dotProduct(Vector4 v)
Compute the dot product of two vectors

Parameters:
v - the second vector
Returns:
the dotproduct in floating point

add

public Vector4 add(Vector4 b)
Adds a vector to current vector.

Parameters:
b - The vector to add
Returns:
the resulting vector

sub

public Vector4 sub(Vector4 b)
Subtracts a vector from current vector.

Parameters:
b - The vector to subtract
Returns:
the resulting vector

sub

public static Vector4 sub(Vector4 a,
                          Vector4 b)
Subtracts a vector from current vector.

Parameters:
a - The first vector
b - The vector to subtract
Returns:
a new resulting vector

project

public Vector4 project(Vector4 vect3D,
                       Camera c)
Projects a point in world coordinates to the origin cameras viewplane. The coordinates are not converted to pixel coordinates. The projected vector is NOT changed.

Parameters:
vect3D - the 3d-point to project
c - the camera whose viewplane the point is to be projected to
Returns:
the projected point as a vector

project

public Vector4 project(Camera c)
Projects a point in world coordinates to the origin cameras viewplane. The coordinates are not converted to pixel coordinates. The projected vector is changed.

Parameters:
c - the camera whose viewplane the point is to be projected to
Returns:
the projected point as a vector

world2pixel

public Vector4 world2pixel(Camera c)
Convert world coordinates to image coordinates, no projection.

Parameters:
c - The camera containing the image coordinates.
Returns:
the converted vector

pixel2world

public Vector4 pixel2world(Camera c)
Convert image coordinates to world coordinates, no projection.

Parameters:
c - The camera containing the image coordinates.
Returns:
the converted vector