es.ucm.look.ar.math.geom
Class Vector3

java.lang.Object
  extended by es.ucm.look.ar.math.geom.Point2
      extended by es.ucm.look.ar.math.geom.Point3
          extended by es.ucm.look.ar.math.geom.Vector3

public class Vector3
extends Point3

Represents a 3 dimensions vector


Field Summary
 
Fields inherited from class es.ucm.look.ar.math.geom.Point3
z
 
Fields inherited from class es.ucm.look.ar.math.geom.Point2
x, y
 
Constructor Summary
Vector3(float x, float y, float z)
          Constructs a vector from its 3 coordinates
Vector3(Point3 v)
          Constructs a vector from another vector.
Vector3(Point3 p1, Point3 p2)
          Constructs a vector that points from p1 to p2
 
Method Summary
 void add(Vector3 v, boolean normalize)
          Adds a vector and then, if normalize is true normalize the vector
 float angle(Vector3 v)
          Returns the formed angle with the given vector
 Vector3 crossProduct(Vector3 v)
          Returns the cross product with the given vector
 float dotProduct(Vector3 v)
          Returns the dot product with the given vector
 int getGreatestComponent()
          Returns the index from the vector's greatest absolute coordinate
static Vector3 getVolatileVector(float x1, float y1, float z1, float x2, float y2, float z2)
           
static Vector3 getVolatileVector(Point3 p1, Point3 p2)
          Returns a volatile vector pointing from p1 to p2.
 float module()
          Returns vector module
 float module2()
          Returns module's square, avoiding do the square root
 void normalize()
          Normalize the vector
static Vector3 normalVector(Point3 p1, Point3 p2, Point3 p3)
          Returns the normal vector to the plane formed by the 3 given points
 void preMultiply(float[] m)
          Premultiply the vector with a matrix
 void rotateX(float rotX)
          Rotate the vector around x-axis
 void rotateY(float angle)
          Rotate the vector around y-axis
 void rotateZ(float rotZ)
          Rotate the vector around z-axis
 void scale(float k)
          Scales the vector
 void set(float x, float y, float z)
          Sets point coordinates
 void set(float x1, float y1, float z1, float x2, float y2, float z2)
          Creates the vector form point defined by (x1, y1, z1) to point defined by (x2, y2, z2)
 void set(Point3 p1, Point3 p2)
          Creates a vector from point p1 to point p2
 
Methods inherited from class es.ucm.look.ar.math.geom.Point3
add, add, array, getCoordinatesArray, getVolatilePoint, inverseScale, scale, set, set, subtract, toString
 
Methods inherited from class es.ucm.look.ar.math.geom.Point2
add, add
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vector3

public Vector3(float x,
               float y,
               float z)
Constructs a vector from its 3 coordinates

Parameters:
x - x coordinate
y - y coordinate
z - z coordinate

Vector3

public Vector3(Point3 v)
Constructs a vector from another vector. It just clones its coordinates

Parameters:
v -

Vector3

public Vector3(Point3 p1,
               Point3 p2)
Constructs a vector that points from p1 to p2

Parameters:
p1 - Starting point for the vector
p2 - Finish point for the vector
Method Detail

add

public void add(Vector3 v,
                boolean normalize)
Adds a vector and then, if normalize is true normalize the vector

Parameters:
v - the vector to be added
normalize - if the vector must be normalized after the addition

angle

public float angle(Vector3 v)
Returns the formed angle with the given vector

Parameters:
v - the vector
Returns:
the tiniest angle between the two vectors at the plane formed by both

crossProduct

public Vector3 crossProduct(Vector3 v)
Returns the cross product with the given vector

Parameters:
v - the vector
Returns:
the vector result from the cross product

dotProduct

public float dotProduct(Vector3 v)
Returns the dot product with the given vector

Parameters:
v - the vector
Returns:
the dot product

getGreatestComponent

public int getGreatestComponent()
Returns the index from the vector's greatest absolute coordinate

Returns:
the index from the vector's greatest absolute coordinate. 0 for the x, 1 for the y, 2 for the z

getVolatileVector

public static Vector3 getVolatileVector(float x1,
                                        float y1,
                                        float z1,
                                        float x2,
                                        float y2,
                                        float z2)

getVolatileVector

public static Vector3 getVolatileVector(Point3 p1,
                                        Point3 p2)
Returns a volatile vector pointing from p1 to p2. We use a the volatile vector when we want to do calculations with vectors, but it's not necessary to keep the instance


module

public float module()
Returns vector module

Returns:
vector module

module2

public float module2()
Returns module's square, avoiding do the square root

Returns:

normalize

public void normalize()
Normalize the vector


normalVector

public static Vector3 normalVector(Point3 p1,
                                   Point3 p2,
                                   Point3 p3)
Returns the normal vector to the plane formed by the 3 given points

Parameters:
p1 - point 1
p2 - point 2
p3 - point 3
Returns:
the normal vector to the plane formed by the 3 given points

preMultiply

public void preMultiply(float[] m)
Premultiply the vector with a matrix

Parameters:
m - the matrix

rotateX

public void rotateX(float rotX)
Rotate the vector around x-axis

Parameters:
rotX - rotation in radians

rotateY

public void rotateY(float angle)
Rotate the vector around y-axis

Parameters:
rotY - rotation in radians

rotateZ

public void rotateZ(float rotZ)
Rotate the vector around z-axis

Parameters:
rotZ - rotation in radians

scale

public void scale(float k)
Scales the vector

Parameters:
k - scale factor

set

public void set(float x,
                float y,
                float z)
Description copied from class: Point3
Sets point coordinates

Overrides:
set in class Point3
Parameters:
x - x coordinate
y - y coordinate
z - z coordinate

set

public void set(float x1,
                float y1,
                float z1,
                float x2,
                float y2,
                float z2)
Creates the vector form point defined by (x1, y1, z1) to point defined by (x2, y2, z2)

Parameters:
x1 -
y1 -
z1 -
x2 -
y2 -
z2 -

set

public void set(Point3 p1,
                Point3 p2)
Creates a vector from point p1 to point p2

Parameters:
p1 - start point
p2 - end point