org.openmali.vecmath2.util
Class TupleUtils

java.lang.Object
  extended by org.openmali.vecmath2.util.TupleUtils

public final class TupleUtils
extends java.lang.Object

Some functions which can operate on Tuples, since some of the functions for points are not available to vectors in general.


Method Summary
static float angle(Tuple3f v1, Tuple3f v2)
          Returns the angle in radians between the vectors v1 and v2.
static int compareTuple(Tuple3f ta, Tuple3f tb)
           
static AxisAngle3f computeRotation(Tuple3f v1, Tuple3f v2, int normalize, AxisAngle3f result)
          Computes the rotation between the vectors v1 ans v2.
static
<T extends Tuple3f>
T
cross(Tuple3f v1, Tuple3f v2, T result)
          Sets the result-vector to be the vector cross product of vectors v1 and v2.
static float distanceSquared(Tuple3f a, Tuple3f b)
           
static float dot(Tuple3f v1, Tuple3f v2)
          Computes the dot product of the vectors v1 and vector v2.
static boolean limit(Tuple3f tuple, float maxx, float maxy)
          Limits the tuple into a rectangle (0, 0, maxx, maxy).
static boolean limit(Tuple3f tuple, float minx, float miny, float maxx, float maxy)
          Limits the tuple in a rectangle.
static
<T extends Tuple3f>
T
normalizeVector(T vector)
          Normalize the input vector.
static float vectorLength(Tuple3f v)
           
static float vectorLengthSquared(Tuple3f v)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

normalizeVector

public static final <T extends Tuple3f> T normalizeVector(T vector)
Normalize the input vector.

Parameters:
vector - the input vector to normalize
Returns:
the input vector back again

distanceSquared

public static float distanceSquared(Tuple3f a,
                                    Tuple3f b)

vectorLengthSquared

public static final float vectorLengthSquared(Tuple3f v)
Returns:
the squared length of a vector

vectorLength

public static final float vectorLength(Tuple3f v)
Returns:
the length of a vector

cross

public static final <T extends Tuple3f> T cross(Tuple3f v1,
                                                Tuple3f v2,
                                                T result)
Sets the result-vector to be the vector cross product of vectors v1 and v2.

Parameters:
v1 - the first vector
v2 - the second vector
result - the result vector
Returns:
the result vector back again

dot

public static final float dot(Tuple3f v1,
                              Tuple3f v2)
Computes the dot product of the vectors v1 and vector v2.

Parameters:
v1 - the first vector
v2 - the second vector

angle

public static final float angle(Tuple3f v1,
                                Tuple3f v2)
Returns the angle in radians between the vectors v1 and v2. The return value is constrained to the range [0,PI].

Parameters:
v1 - the first vector
v2 - the second vector
Returns:
the angle in radians in the range [0,PI]

compareTuple

public static int compareTuple(Tuple3f ta,
                               Tuple3f tb)

limit

public static boolean limit(Tuple3f tuple,
                            float minx,
                            float miny,
                            float maxx,
                            float maxy)
Limits the tuple in a rectangle.

Parameters:
tuple -
minx -
miny -
maxx -
maxy -
Returns:
true if was outside

limit

public static boolean limit(Tuple3f tuple,
                            float maxx,
                            float maxy)
Limits the tuple into a rectangle (0, 0, maxx, maxy).

Parameters:
tuple -
maxx -
maxy -
Returns:
true if was outside

computeRotation

public static final AxisAngle3f computeRotation(Tuple3f v1,
                                                Tuple3f v2,
                                                int normalize,
                                                AxisAngle3f result)
Computes the rotation between the vectors v1 ans v2.

Parameters:
v1 - the first vector
v2 - the second vector
normalize - normalize input vectors (bitmask)
result - the result object
Returns:
the result object back again