hmi.math
Class Vec4f

java.lang.Object
  extended by hmi.math.Vec4f

public final class Vec4f
extends Object

A collection of static methods for vectors of length 4, represented by float arrays.

Author:
Job Zwiers, Herwin van Welbergen

Field Summary
static int A
           
static int B
           
private static int BUFSIZE
           
static int G
           
static int R
           
static int VEC4F_SIZE
          Length of Vec4f arrays is 4
static int W
           
static int X
          Offset values for Vec4 vectors.
static int Y
           
static int Z
           
 
Constructor Summary
private Vec4f()
           
 
Method Summary
static void add(float[] dst, float[] a)
          Adds vector a to vector dst
static void add(float[] dst, float[] a, float[] b)
          Adds vector a and b, puts result in dest.
static void add(float[] dst, int dstIndex, float[] a, int aIndex)
          Adds vector b to vector a.
static void add(float[] dst, int dstIndex, float[] a, int aIndex, float[] b, int bIndex)
          Sets vector dst to sum of a and b.
static float dot(float[] a, float[] b)
          Calculates the dot product for two vectors of length 4
static float dot(float[] a, int aIndex, float[] b, int bIndex)
          Calculates the dot product for two vectors of length 4
static boolean epsilonEquals(float[] a, float[] b, float epsilon)
          Tests for equality of vector components within epsilon.
static boolean epsilonEquals(float[] a, float b0, float b1, float b2, float b3, float epsilon)
          Tests for equality of vector components within epsilon.
static boolean epsilonEquals(float[] a, int aIndex, float[] b, int bIndex, float epsilon)
          Tests for equality of vector components within epsilon.
static boolean equals(float[] a, float[] b)
          Tests for equality of two vectors
static boolean equals(float[] a, int aIndex, float[] b, int bIndex)
          Tests for equality of two vectors
static float[] getVec4f()
          Returns a new float[4] array with zero components
static float[] getVec4f(float[] vec4f)
          Rturns a new float[4] array with initialized components
static float[] getVec4f(float x, float y, float z, float a)
          Returns a new float[4] array with initialized components
static void interpolate(float[] dst, float[] a, float[] b, float alpha)
          Linear interpolates between vector a and b, and puts the result in vector dst: dst = (1-alpha)*a + alpha*b
static void interpolate(float[] dst, int dstIndex, float[] a, int aIndex, float[] b, int bIndex, float alpha)
          Linear interpolates between vector a and b, and puts the result in vector dst: dst = (1-alpha)*a + alpha*b
static float length(float[] a)
          returns the vector length
static float length(float[] a, int aIndex)
          returns the vector length
static float lengthSq(float[] a)
          returns the square of the vector length
static float lengthSq(float[] a, int aIndex)
          returns the square of the vector length
static void negate(float[] dst)
          Negates a vector
static void negate(float[] dst, float[] src)
          Sets vector dst to the negated version of vector src
static void negate(float[] dst, int dstIndex)
          Negates a vector
static void negate(float[] dst, int dstIndex, float[] src, int srcIndex)
          Sets vector dst to the negated version of vector src
static void normalize(float[] a)
          Normalizes a, that is, a = a/|a|
static void normalize(float[] dst, float[] a)
          Normalizes a, that is, dst = a/|a|
static void normalize(float[] a, int aIndex)
          Normalizes a, that is, a = a/|a|
static void normalize(float[] dst, int dstIndex, float[] a, int aIndex)
          Normalizes a, that is, a = a/|a|
static void pmul(float[] u, float[] v)
          Performs pointwise multiplication of two vectors: u[i] = u[i]*v[i];
static void scale(float scale, float[] dst)
          Scales a vector
static void scale(float scale, float[] dst, int dstIndex)
          Scales a vector
static void scaleAdd(float[] dst, float scale, float[] a, float[] b)
          Sets vector dst to scaled version of vector a, then adds vector b dst = s*a + b
static void scaleAdd(float[] dst, int dstIndex, float scale, float[] a, int aIndex, float[] b, int bIndex)
          Sets vector a to scaled version of vector b, then adds vector c a = s*b + c
static void scaleAdd(float scale, float[] dst, float[] a)
          First scales vector dst, then and adds vector a.
static void scaleAdd(float scale, float[] dst, int dstIndex, float[] a, int aIndex)
          First scales vector dst, then and adds vector a.
static void set(float[] dst, float[] src)
          Copies vector src to vector dst
static void set(float[] dst, float x, float y, float z, float w)
          Sets vector components tp specified float values.
static void set(float[] dst, int dstIndex, float[] src, int srcIndex)
          Copies vector src to vector dst
static void set(float[] dst, int dstIndex, float x, float y, float z, float w)
          Sets vector components to specified float values.
static void setZero(float[] dst)
          Resets the Vec4f to (0, 0, 0, 0)
static void sub(float[] dst, float[] a)
          Subtracts vector a from vector dst.
static void sub(float[] dst, float[] a, float[] b)
          Adds vector a and b, puts result in dest.
static void sub(float[] dst, int dstIndex, float[] a, int aIndex)
          Subtracts vector a from vector dst.
static void sub(float[] dst, int dstIndex, float[] a, int aIndex, float[] b, int bIndex)
          Sets vector dst to a minus b
static String toString(float[] a)
           
static String toString(float[] a, int aIndex)
           
static String toString(float[] a, int fieldwidth, int precision)
          Returns a String of the form (x, y, z), representing the Vec3f value.
static String toString(float[] a, String fmt)
          Returns a String of the form (x, y, z), representing the Vec3f value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VEC4F_SIZE

public static final int VEC4F_SIZE
Length of Vec4f arrays is 4

See Also:
Constant Field Values

X

public static final int X
Offset values for Vec4 vectors. Names are appropriate for homogeneous coordinates and colors

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

W

public static final int W
See Also:
Constant Field Values

R

public static final int R
See Also:
Constant Field Values

G

public static final int G
See Also:
Constant Field Values

B

public static final int B
See Also:
Constant Field Values

A

public static final int A
See Also:
Constant Field Values

BUFSIZE

private static final int BUFSIZE
See Also:
Constant Field Values
Constructor Detail

Vec4f

private Vec4f()
Method Detail

getVec4f

public static float[] getVec4f()
Returns a new float[4] array with zero components


getVec4f

public static float[] getVec4f(float x,
                               float y,
                               float z,
                               float a)
Returns a new float[4] array with initialized components


getVec4f

public static float[] getVec4f(float[] vec4f)
Rturns a new float[4] array with initialized components


equals

public static boolean equals(float[] a,
                             int aIndex,
                             float[] b,
                             int bIndex)
Tests for equality of two vectors


equals

public static boolean equals(float[] a,
                             float[] b)
Tests for equality of two vectors


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    int aIndex,
                                    float[] b,
                                    int bIndex,
                                    float epsilon)
Tests for equality of vector components within epsilon.


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    float[] b,
                                    float epsilon)
Tests for equality of vector components within epsilon.


epsilonEquals

public static boolean epsilonEquals(float[] a,
                                    float b0,
                                    float b1,
                                    float b2,
                                    float b3,
                                    float epsilon)
Tests for equality of vector components within epsilon.


setZero

public static void setZero(float[] dst)
Resets the Vec4f to (0, 0, 0, 0)


set

public static void set(float[] dst,
                       int dstIndex,
                       float[] src,
                       int srcIndex)
Copies vector src to vector dst


set

public static void set(float[] dst,
                       float[] src)
Copies vector src to vector dst


set

public static void set(float[] dst,
                       int dstIndex,
                       float x,
                       float y,
                       float z,
                       float w)
Sets vector components to specified float values.


set

public static void set(float[] dst,
                       float x,
                       float y,
                       float z,
                       float w)
Sets vector components tp specified float values.


add

public static void add(float[] dst,
                       int dstIndex,
                       float[] a,
                       int aIndex,
                       float[] b,
                       int bIndex)
Sets vector dst to sum of a and b.


add

public static void add(float[] dst,
                       int dstIndex,
                       float[] a,
                       int aIndex)
Adds vector b to vector a.


add

public static void add(float[] dst,
                       float[] a,
                       float[] b)
Adds vector a and b, puts result in dest.


add

public static void add(float[] dst,
                       float[] a)
Adds vector a to vector dst


sub

public static void sub(float[] dst,
                       int dstIndex,
                       float[] a,
                       int aIndex,
                       float[] b,
                       int bIndex)
Sets vector dst to a minus b


sub

public static void sub(float[] dst,
                       int dstIndex,
                       float[] a,
                       int aIndex)
Subtracts vector a from vector dst.


sub

public static void sub(float[] dst,
                       float[] a,
                       float[] b)
Adds vector a and b, puts result in dest.


sub

public static void sub(float[] dst,
                       float[] a)
Subtracts vector a from vector dst.


scale

public static void scale(float scale,
                         float[] dst,
                         int dstIndex)
Scales a vector


scale

public static void scale(float scale,
                         float[] dst)
Scales a vector


scaleAdd

public static void scaleAdd(float[] dst,
                            int dstIndex,
                            float scale,
                            float[] a,
                            int aIndex,
                            float[] b,
                            int bIndex)
Sets vector a to scaled version of vector b, then adds vector c a = s*b + c


scaleAdd

public static void scaleAdd(float[] dst,
                            float scale,
                            float[] a,
                            float[] b)
Sets vector dst to scaled version of vector a, then adds vector b dst = s*a + b


scaleAdd

public static void scaleAdd(float scale,
                            float[] dst,
                            int dstIndex,
                            float[] a,
                            int aIndex)
First scales vector dst, then and adds vector a. dst = s*dst + a


scaleAdd

public static void scaleAdd(float scale,
                            float[] dst,
                            float[] a)
First scales vector dst, then and adds vector a. dst = s*dst + a


negate

public static void negate(float[] dst,
                          int dstIndex,
                          float[] src,
                          int srcIndex)
Sets vector dst to the negated version of vector src


negate

public static void negate(float[] dst,
                          float[] src)
Sets vector dst to the negated version of vector src


negate

public static void negate(float[] dst,
                          int dstIndex)
Negates a vector


negate

public static void negate(float[] dst)
Negates a vector


dot

public static float dot(float[] a,
                        float[] b)
Calculates the dot product for two vectors of length 4


dot

public static float dot(float[] a,
                        int aIndex,
                        float[] b,
                        int bIndex)
Calculates the dot product for two vectors of length 4


lengthSq

public static float lengthSq(float[] a,
                             int aIndex)
returns the square of the vector length


lengthSq

public static float lengthSq(float[] a)
returns the square of the vector length


length

public static float length(float[] a,
                           int aIndex)
returns the vector length


length

public static float length(float[] a)
returns the vector length


interpolate

public static void interpolate(float[] dst,
                               int dstIndex,
                               float[] a,
                               int aIndex,
                               float[] b,
                               int bIndex,
                               float alpha)
Linear interpolates between vector a and b, and puts the result in vector dst: dst = (1-alpha)*a + alpha*b


interpolate

public static void interpolate(float[] dst,
                               float[] a,
                               float[] b,
                               float alpha)
Linear interpolates between vector a and b, and puts the result in vector dst: dst = (1-alpha)*a + alpha*b


normalize

public static void normalize(float[] dst,
                             int dstIndex,
                             float[] a,
                             int aIndex)
Normalizes a, that is, a = a/|a|

Parameters:
a - vector to be normalized
aIndex - index in a array
dst - vector to receive the result
dstIndex - index in dst array

normalize

public static void normalize(float[] a,
                             int aIndex)
Normalizes a, that is, a = a/|a|

Parameters:
a - vector to be normalized
aIndex - index in a array

normalize

public static void normalize(float[] dst,
                             float[] a)
Normalizes a, that is, dst = a/|a|

Parameters:
a - vector to be normalized
dst - vector to receive the result

normalize

public static void normalize(float[] a)
Normalizes a, that is, a = a/|a|

Parameters:
a - vector to be normalized

pmul

public static void pmul(float[] u,
                        float[] v)
Performs pointwise multiplication of two vectors: u[i] = u[i]*v[i];


toString

public static String toString(float[] a,
                              int aIndex)

toString

public static String toString(float[] a)

toString

public static String toString(float[] a,
                              int fieldwidth,
                              int precision)
Returns a String of the form (x, y, z), representing the Vec3f value.


toString

public static String toString(float[] a,
                              String fmt)
Returns a String of the form (x, y, z), representing the Vec3f value.