mathematik
Class Vector3f

java.lang.Object
  extended by mathematik.Vector3f
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Vector3f>, Vectorf

public class Vector3f
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, java.lang.Comparable<Vector3f>, Vectorf

See Also:
Serialized Form

Field Summary
static int COMPARE_TYPE
           
static int LENGTH
           
 float x
          The x coordinate of the vector
static int X
           
 float y
          The y coordinate of the vector
static int Y
           
 float z
          The z coordinate of the vector
static int Z
           
 
Constructor Summary
Vector3f()
          Initializes a new vector.
Vector3f(double[] theVector)
           
Vector3f(double theX, double theY)
           
Vector3f(double theX, double theY, double theZ)
           
Vector3f(float[] theVector)
           
Vector3f(float theX, float theY)
           
Vector3f(float theX, float theY, float theZ)
          Creates a new vector with the given coordinates.
Vector3f(int[] theVector)
           
Vector3f(java.lang.String theVector)
           
Vector3f(Vector2f theVector)
           
Vector3f(Vector2i theVector)
           
Vector3f(Vector3f theVector)
           
Vector3f(Vector3i theVector)
           
 
Method Summary
 void add(float theX, float theY)
           
 void add(float theX, float theY, float theZ)
           
 void add(Vector3f theVector)
           
 void add(Vector3f theVectorA, Vector3f theVectorB)
           
 boolean almost(Vector3f theVector)
           
 float angle(Vector3f theVector)
           
 java.lang.Object clone()
           
 int compareTo(Vector3f theVector3f)
           
 Vector3f cross(Vector3f theVector)
          Returns the cross product of two vectors.
 void cross(Vector3f theVectorA, Vector3f theVectorB)
          Sets this vector to the cross product of two given vectors.
 float distance(Vector3f thePoint)
           
 float distanceL1(Vector3f thePoint)
           
 float distanceSquared(Vector3f thePoint)
           
 void divide(float theDivisor)
          Dividing is nearly the the same as scaling, except
 void divide(Vector3f theVector)
           
 float dot(Vector3f theVector)
          Returns the dot product of two vectors.
 boolean equals(java.lang.Object theVector)
           
 boolean equals(Vector3f theVector)
           
 void interpolate(float blend, Vector3f i_vector)
          Interpolates between this vector and the given vector by a given blend value.
 boolean isNaN()
           
 float length()
          Use this method to calculate the length of a vector, the length of a vector is also known as its magnitude.
 float lengthSquared()
           
 float magnitude()
           
 void max(float theX, float theY, float theZ)
           
 void max(Vector3f theMax)
           
 void min(float theX, float theY, float theZ)
           
 void min(Vector3f theMin)
           
 void negate()
          Use this method to negate a vector.
 void normalize()
          Norms the vector to the length of 1
 void normalize(Vector3f theVector)
          Sets the vector to the given one and norms it to the length of 1
 void randomize()
          Sets a position randomly distributed inside a sphere of unit radius centered at the origin.
 void scale(float theScalar)
          Use this method to scale a vector.
 void scale(float theX, float theY, float theZ)
           
 void scale(float theScalar, Vector3f theVector)
           
 void scale(Vector3f theVector)
           
 void set(double[] theVector)
           
 void set(double theX, double theY)
           
 void set(double theX, double theY, double theZ)
           
 void set(float[] theVector)
           
 void set(float theX, float theY)
           
 void set(float theX, float theY, float theZ)
           
 void set(int[] theVector)
           
 void set(java.lang.String theVectorString)
           
 void set(Vector2f theVector)
           
 void set(Vector2i theVector)
           
 void set(Vector3f theVector)
           
 void set(Vector3i theVector)
           
 void sub(Vector3f theVector)
           
 void sub(Vector3f theVectorA, Vector3f theVectorB)
           
 float[] toArray()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public float x
The x coordinate of the vector


y

public float y
The y coordinate of the vector


z

public float z
The z coordinate of the vector


X

public static final int X
See Also:
Constant Field Values

Y

public static final int Y
See Also:
Constant Field Values

Z

public static final int Z
See Also:
Constant Field Values

LENGTH

public static final int LENGTH
See Also:
Constant Field Values

COMPARE_TYPE

public static int COMPARE_TYPE
Constructor Detail

Vector3f

public Vector3f()
Initializes a new vector. x, y, and z are set to zero.


Vector3f

public Vector3f(float theX,
                float theY,
                float theZ)
Creates a new vector with the given coordinates. Inserted double values are casted to floats

Parameters:
theX - int, float or double: x coord of the new vector
theY - int, float or double: y coord of the new vector
theZ - int, float or double: z coord of the new vector

Vector3f

public Vector3f(double theX,
                double theY,
                double theZ)

Vector3f

public Vector3f(float theX,
                float theY)

Vector3f

public Vector3f(double theX,
                double theY)

Vector3f

public Vector3f(float[] theVector)

Vector3f

public Vector3f(double[] theVector)

Vector3f

public Vector3f(int[] theVector)

Vector3f

public Vector3f(Vector3f theVector)

Vector3f

public Vector3f(Vector2f theVector)

Vector3f

public Vector3f(Vector3i theVector)

Vector3f

public Vector3f(Vector2i theVector)

Vector3f

public Vector3f(java.lang.String theVector)
Method Detail

set

public final void set(float theX,
                      float theY,
                      float theZ)

set

public final void set(double theX,
                      double theY,
                      double theZ)

set

public final void set(float theX,
                      float theY)

set

public final void set(double theX,
                      double theY)

set

public final void set(float[] theVector)

set

public final void set(double[] theVector)

set

public final void set(int[] theVector)

set

public final void set(Vector3f theVector)

set

public final void set(Vector2f theVector)

set

public final void set(Vector3i theVector)

set

public final void set(Vector2i theVector)

set

public final void set(java.lang.String theVectorString)

add

public final void add(Vector3f theVectorA,
                      Vector3f theVectorB)

add

public final void add(Vector3f theVector)

add

public final void add(float theX,
                      float theY)

add

public final void add(float theX,
                      float theY,
                      float theZ)

sub

public final void sub(Vector3f theVectorA,
                      Vector3f theVectorB)

sub

public final void sub(Vector3f theVector)

negate

public final void negate()
Use this method to negate a vector. The result of the negation is vector with the same magnitude but opposite direction. Mathematically the negation is the additive inverse of the vector. The sum of a value and its additive inerse is always zero.


scale

public final void scale(float theScalar)
Use this method to scale a vector. To scale a vector each of its coordinates is multiplied with the given scalar. The result is a vector that is parallel with its origin, with a different length and possibly opposite direction.
You can also scale a vector with another vector, in this case each coord of the vector is multiplied with related coord of the given vector.
Another possibillity is to set and scale the vector, this means the vector is set to the given vector multiplied with the given scalar.

Parameters:
theScalar - float or int: the value the vector is scaled with

scale

public final void scale(Vector3f theVector)
Parameters:
theVector - Vector3f: vector with the value each coord is scaled with

scale

public final void scale(float theX,
                        float theY,
                        float theZ)
Parameters:
theX - float
theY - float
theZ - float

scale

public final void scale(float theScalar,
                        Vector3f theVector)
Parameters:
theScalar - float or int: value the given vector is scaled with
theVector - Vector3f: vector the vector is set to

divide

public final void divide(float theDivisor)
Dividing is nearly the the same as scaling, except

Parameters:
theDivisor -

divide

public final void divide(Vector3f theVector)

lengthSquared

public final float lengthSquared()

length

public final float length()
Use this method to calculate the length of a vector, the length of a vector is also known as its magnitude. Vectors have a magnitude and a direction. These values are not explicitly expressed in the vector so they have to be computed.

Returns:
float: the length of the vector

magnitude

public final float magnitude()

cross

public final void cross(Vector3f theVectorA,
                        Vector3f theVectorB)
Sets this vector to the cross product of two given vectors. The cross product returns a vector standing vertical on the two vectors.

Parameters:
theVectorA -
theVectorB -

cross

public Vector3f cross(Vector3f theVector)
Returns the cross product of two vectors. The cross product returns a vector standing vertical on the two vectors.

Parameters:
i_vector - the other vector
Returns:
the cross product

dot

public final float dot(Vector3f theVector)
Returns the dot product of two vectors. The dot product is the cosinus of the angle between two vectors

Parameters:
theVector, - the other vector
Returns:
float, dot product of two vectors

normalize

public final void normalize(Vector3f theVector)
Sets the vector to the given one and norms it to the length of 1


normalize

public final void normalize()
Norms the vector to the length of 1


interpolate

public void interpolate(float blend,
                        Vector3f i_vector)
Interpolates between this vector and the given vector by a given blend value. The blend value has to be between 0 and 1. A blend value 0 would change nothing, a blend value 1 would set this vector to the given one.

Parameters:
blend - float, blend value for interpolation
i_vector - Vector3f, other vector for interpolation

randomize

public void randomize()
Sets a position randomly distributed inside a sphere of unit radius centered at the origin. Orientation will be random and length will range between 0 and 1


angle

public final float angle(Vector3f theVector)

distanceSquared

public final float distanceSquared(Vector3f thePoint)

distance

public final float distance(Vector3f thePoint)

distanceL1

public final float distanceL1(Vector3f thePoint)

min

public final void min(Vector3f theMin)

min

public final void min(float theX,
                      float theY,
                      float theZ)

max

public final void max(Vector3f theMax)

max

public final void max(float theX,
                      float theY,
                      float theZ)

toArray

public final float[] toArray()

isNaN

public final boolean isNaN()

equals

public final boolean equals(Vector3f theVector)

equals

public final boolean equals(java.lang.Object theVector)
Overrides:
equals in class java.lang.Object

almost

public final boolean almost(Vector3f theVector)

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(Vector3f theVector3f)
Specified by:
compareTo in interface java.lang.Comparable<Vector3f>


processing library gestalt_p5 by Patrick Kochlik + Dennis Paul. (c) 2009