Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.vecmath
Class GVector

    java.lang.Object
      javax.vecmath.GVector

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable

    public class GVector

extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

A double precision, general, dynamically-resizable, one-dimensional vector class. Index numbering begins with zero.

See Also:
  Serialized Form

Constructor Summary
`GVector(double[] vector)` Constructs a new GVector from the specified array elements.
`GVector(double[] vector, int length)` Constructs a new GVector of the specified length and initializes it by copying the specified number of elements from the specified array.
`GVector(GVector vector)` Constructs a new GVector from the specified vector.
`GVector(int length)` Constructs a new GVector of the specified length with all vector elements initialized to 0.
`GVector(Tuple2f tuple)` Constructs a new GVector and copies the initial values from the specified tuple.
`GVector(Tuple3d tuple)` Constructs a new GVector and copies the initial values from the specified tuple.
`GVector(Tuple3f tuple)` Constructs a new GVector and copies the initial values from the specified tuple.
`GVector(Tuple4d tuple)` Constructs a new GVector and copies the initial values from the specified tuple.
`GVector(Tuple4f tuple)` Constructs a new GVector and copies the initial values from the specified tuple.

Method Summary
`void` | `add(GVector vector)` Sets the value of this vector to sum of itself and the specified vector
`void` | `add(GVector vector1, GVector vector2)` Sets the value of this vector to the vector sum of vectors vector1 and vector2.
`double` | `angle(GVector v1)` Returns the (n-space) angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].
`java.lang.Object` | `clone()` Creates a new object of the same class as this object.
`double` | `dot(GVector v1)` Returns the dot product of this vector and vector v1.
`boolean` | `epsilonEquals(GVector v1, double epsilon)` Returns true if the L-infinite distance between this vector and vector v1 is less than or equal to the epsilon parameter, otherwise returns false.
`boolean` | `equals(GVector vector1)` Returns true if all of the data members of GVector vector1 are equal to the corresponding data members in this GVector.
`boolean` | `equals(java.lang.Object o1)` Returns true if the Object o1 is of type GMatrix and all of the data members of o1 are equal to the corresponding data members in this GMatrix.
`double` | `getElement(int index)` Retrieves the value at the specified index value of this vector.
`int` | `getSize()` Returns the number of elements in this vector.
`int` | `hashCode()` Returns a hash code value based on the data values in this object.
`void` | `interpolate(GVector v1, double alpha)` Linearly interpolates between this vector and vector v1 and places the result into this tuple: this = (1-alpha)*this + alpha*v1.
`void` | `interpolate(GVector v1, float alpha)` Deprecated. Use interpolate(GVector, double) instead
`void` | `interpolate(GVector v1, GVector v2, double alpha)` Linearly interpolates between vectors v1 and v2 and places the result into this tuple: this = (1-alpha)*v1 + alpha*v2.
`void` | `interpolate(GVector v1, GVector v2, float alpha)` Deprecated. Use interpolate(GVector, GVector, double) instead
`void` | `LUDBackSolve(GMatrix LU, GVector b, GVector permutation)` LU Decomposition Back Solve; this method takes the LU matrix and the permutation vector produced by the GMatrix method LUD and solves the equation (LU)*x = b by placing the solution vector x into this vector.
`void` | `mul(GMatrix m1, GVector v1)` Multiplies matrix m1 times Vector v1 and places the result into this vector (this = m1*v1).
`void` | `mul(GVector v1, GMatrix m1)` Multiplies the transpose of vector v1 (ie, v1 becomes a row vector with respect to the multiplication) times matrix m1 and places the result into this vector (this = transpose(v1)*m1).
`void` | `negate()` Negates the value of this vector: this = -this.
`double` | `norm()` Returns the square root of the sum of the squares of this vector (its length in n-dimensional space).
`void` | `normalize()` Normalizes this vector in place.
`void` | `normalize(GVector v1)` Sets the value of this vector to the normalization of vector v1.
`double` | `normSquared()` Returns the sum of the squares of this vector (its length squared in n-dimensional space).
`void` | `scale(double s)` Scales this vector by the scale factor s.
`void` | `scale(double s, GVector v1)` Sets the value of this vector to the scalar multiplication of the scale factor with the vector v1.
`void` | `scaleAdd(double s, GVector v1, GVector v2)` Sets the value of this vector to the scalar multiplication by s of vector v1 plus vector v2 (this = s*v1 + v2).
`void` | `set(double[] vector)` Sets the value of this vector to the values found in the array parameter.
`void` | `set(GVector vector)` Sets the value of this vector to the values found in vector vector.
`void` | `set(Tuple2f tuple)` Sets the value of this vector to the values in tuple
`void` | `set(Tuple3d tuple)` Sets the value of this vector to the values in tuple
`void` | `set(Tuple3f tuple)` Sets the value of this vector to the values in tuple
`void` | `set(Tuple4d tuple)` Sets the value of this vector to the values in tuple
`void` | `set(Tuple4f tuple)` Sets the value of this vector to the values in tuple
`void` | `setElement(int index, double value)` Modifies the value at the specified index of this vector.
`void` | `setSize(int length)` Changes the size of this vector dynamically.
`void` | `sub(GVector vector)` Sets the value of this vector to the vector difference of itself and vector (this = this - vector).
`void` | `sub(GVector vector1, GVector vector2)` Sets the value of this vector to the vector difference of vectors vector1 and vector2 (this = vector1 - vector2).
`void` | `SVDBackSolve(GMatrix U, GMatrix W, GMatrix V, GVector b)` Solves for x in Ax = b, where x is this vector (nx1), A is mxn, b is mx1, and A = U*W*transpose(V); U,W,V must be precomputed and can be found by taking the singular value decomposition (SVD) of A using the method SVD found in the GMatrix class.
`java.lang.String` | `toString()` Returns a string that contains the values of this GVector.
`void` | `zero()` Sets all the values in this vector to zero.

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### GVector

    public GVector(int length)

  Constructs a new GVector of the specified length with all vector elements initialized to 0.

  Parameters:
    `length` - the number of elements in this GVector.

### GVector

    public GVector(double[] vector)

  Constructs a new GVector from the specified array elements. The length of this GVector is set to the length of the specified array. The array elements are copied into this new GVector.

  Parameters:
    `vector` - the values for the new GVector.

### GVector

    public GVector(GVector vector)

  Constructs a new GVector from the specified vector. The vector elements are copied into this new GVector.

  Parameters:
    `vector` - the source GVector for this new GVector.

### GVector

    public GVector(Tuple2f tuple)

  Constructs a new GVector and copies the initial values from the specified tuple.

  Parameters:
    `tuple` - the source for the new GVector's initial values

### GVector

    public GVector(Tuple3f tuple)

  Constructs a new GVector and copies the initial values from the specified tuple.

  Parameters:
    `tuple` - the source for the new GVector's initial values

### GVector

    public GVector(Tuple3d tuple)

  Constructs a new GVector and copies the initial values from the specified tuple.

  Parameters:
    `tuple` - the source for the new GVector's initial values

### GVector

    public GVector(Tuple4f tuple)

  Constructs a new GVector and copies the initial values from the specified tuple.

  Parameters:
    `tuple` - the source for the new GVector's initial values

### GVector

    public GVector(Tuple4d tuple)

  Constructs a new GVector and copies the initial values from the specified tuple.

  Parameters:
    `tuple` - the source for the new GVector's initial values

### GVector

    public GVector(double[] vector,
                   int length)

  Constructs a new GVector of the specified length and initializes it by copying the specified number of elements from the specified array. The array must contain at least `length` elements (i.e., `vector.length` >= `length`. The length of this new GVector is set to the specified length.

  Parameters:
    `vector` - The array from which the values will be copied.
    `length` - The number of values copied from the array.

Method Detail

### norm

    public final double norm()

  Returns the square root of the sum of the squares of this vector (its length in n-dimensional space).

  Returns:
    length of this vector

### normSquared

    public final double normSquared()

  Returns the sum of the squares of this vector (its length squared in n-dimensional space).

  Returns:
    length squared of this vector

### normalize

    public final void normalize(GVector v1)

  Sets the value of this vector to the normalization of vector v1.

  Parameters:
    `v1` - the un-normalized vector

### normalize

    public final void normalize()

  Normalizes this vector in place.

### scale

    public final void scale(double s,
                            GVector v1)

  Sets the value of this vector to the scalar multiplication of the scale factor with the vector v1.

  Parameters:
    `s` - the scalar value
    `v1` - the source vector

### scale

    public final void scale(double s)

  Scales this vector by the scale factor s.

  Parameters:
    `s` - the scalar value

### scaleAdd

    public final void scaleAdd(double s,
                               GVector v1,
                               GVector v2)

  Sets the value of this vector to the scalar multiplication by s of vector v1 plus vector v2 (this = s*v1 + v2).

  Parameters:
    `s` - the scalar value
    `v1` - the vector to be multiplied
    `v2` - the vector to be added

### add

    public final void add(GVector vector)

  Sets the value of this vector to sum of itself and the specified vector

  Parameters:
    `vector` - the second vector

### add

    public final void add(GVector vector1,
                          GVector vector2)

  Sets the value of this vector to the vector sum of vectors vector1 and vector2.

  Parameters:
    `vector1` - the first vector
    `vector2` - the second vector

### sub

    public final void sub(GVector vector)

  Sets the value of this vector to the vector difference of itself and vector (this = this - vector).

  Parameters:
    `vector` - the other vector

### sub

    public final void sub(GVector vector1,
                          GVector vector2)

  Sets the value of this vector to the vector difference of vectors vector1 and vector2 (this = vector1 - vector2).

  Parameters:
    `vector1` - the first vector
    `vector2` - the second vector

### mul

    public final void mul(GMatrix m1,
                          GVector v1)

  Multiplies matrix m1 times Vector v1 and places the result into this vector (this = m1*v1).

  Parameters:
    `m1` - The matrix in the multiplication
    `v1` - The vector that is multiplied

### mul

    public final void mul(GVector v1,
                          GMatrix m1)

  Multiplies the transpose of vector v1 (ie, v1 becomes a row vector with respect to the multiplication) times matrix m1 and places the result into this vector (this = transpose(v1)*m1). The result is technically a row vector, but the GVector class only knows about column vectors, and so the result is stored as a column vector.

  Parameters:
    `m1` - The matrix in the multiplication
    `v1` - The vector that is temporarily transposed

### negate

    public final void negate()

  Negates the value of this vector: this = -this.

### zero

    public final void zero()

  Sets all the values in this vector to zero.

### setSize

    public final void setSize(int length)

  Changes the size of this vector dynamically. If the size is increased no data values will be lost. If the size is decreased, only those data values whose vector positions were eliminated will be lost.

  Parameters:
    `length` - number of desired elements in this vector

### set

    public final void set(double[] vector)

  Sets the value of this vector to the values found in the array parameter. The array should be at least equal in length to the number of elements in the vector.

  Parameters:
    `vector` - the source array

### set

    public final void set(GVector vector)

  Sets the value of this vector to the values found in vector vector.

  Parameters:
    `vector` - the source vector

### set

    public final void set(Tuple2f tuple)

  Sets the value of this vector to the values in tuple

  Parameters:
    `tuple` - the source for the new GVector's new values

### set

    public final void set(Tuple3f tuple)

  Sets the value of this vector to the values in tuple

  Parameters:
    `tuple` - the source for the new GVector's new values

### set

    public final void set(Tuple3d tuple)

  Sets the value of this vector to the values in tuple

  Parameters:
    `tuple` - the source for the new GVector's new values

### set

    public final void set(Tuple4f tuple)

  Sets the value of this vector to the values in tuple

  Parameters:
    `tuple` - the source for the new GVector's new values

### set

    public final void set(Tuple4d tuple)

  Sets the value of this vector to the values in tuple

  Parameters:
    `tuple` - the source for the new GVector's new values

### getSize

    public final int getSize()

  Returns the number of elements in this vector.

  Returns:
    number of elements in this vector

### getElement

    public final double getElement(int index)

  Retrieves the value at the specified index value of this vector.

  Parameters:
    `index` - the index of the element to retrieve (zero indexed)
  Returns:
    the value at the indexed element

### setElement

    public final void setElement(int index,
                                 double value)

  Modifies the value at the specified index of this vector.

  Parameters:
    `index` - the index if the element to modify (zero indexed)
    `value` - the new vector element value

### toString

    public java.lang.String toString()

  Returns a string that contains the values of this GVector.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the String representation

### hashCode

    public int hashCode()

  Returns a hash code value based on the data values in this object. Two different GVector objects with identical data values (i.e., GVector.equals returns true) will return the same hash number. Two GVector objects with different data members may return the same hash value, although this is not likely.

  Overrides:
    `hashCode` in class `java.lang.Object`
  Returns:
    the integer hash code value

### equals

    public boolean equals(GVector vector1)

  Returns true if all of the data members of GVector vector1 are equal to the corresponding data members in this GVector.

  Parameters:
    `vector1` - The vector with which the comparison is made.
  Returns:
    true or false

### equals

    public boolean equals(java.lang.Object o1)

  Returns true if the Object o1 is of type GMatrix and all of the data members of o1 are equal to the corresponding data members in this GMatrix.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `o1` - The object with which the comparison is made.
  Returns:
    true or false

### epsilonEquals

    public boolean epsilonEquals(GVector v1,
                                 double epsilon)

  Returns true if the L-infinite distance between this vector and vector v1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2), . . . ].

  Parameters:
    `v1` - The vector to be compared to this vector
    `epsilon` - the threshold value

### dot

    public final double dot(GVector v1)

  Returns the dot product of this vector and vector v1.

  Parameters:
    `v1` - the other vector
  Returns:
    the dot product of this and v1

### SVDBackSolve

    public final void SVDBackSolve(GMatrix U,
                                   GMatrix W,
                                   GMatrix V,
                                   GVector b)

  Solves for x in Ax = b, where x is this vector (nx1), A is mxn, b is mx1, and A = U*W*transpose(V); U,W,V must be precomputed and can be found by taking the singular value decomposition (SVD) of A using the method SVD found in the GMatrix class.

  Parameters:
    `U` - The U matrix produced by the GMatrix method SVD
    `W` - The W matrix produced by the GMatrix method SVD
    `V` - The V matrix produced by the GMatrix method SVD
    `b` - The b vector in the linear equation Ax = b

### LUDBackSolve

    public final void LUDBackSolve(GMatrix LU,
                                   GVector b,
                                   GVector permutation)

  LU Decomposition Back Solve; this method takes the LU matrix and the permutation vector produced by the GMatrix method LUD and solves the equation (LU)*x = b by placing the solution vector x into this vector. This vector should be the same length or longer than b.

  Parameters:
    `LU` - The matrix into which the lower and upper decompostions have been placed
    `b` - The b vector in the equation (LU)*x = b
    `permutation` - The row permuations that were necessary to produce the LU matrix parameter

### angle

    public final double angle(GVector v1)

  Returns the (n-space) angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].

  Parameters:
    `v1` - The other vector
  Returns:
    The angle in radians in the range [0,PI]

### interpolate

    public final void interpolate(GVector v1,
                                  GVector v2,
                                  float alpha)

  Deprecated. Use interpolate(GVector, GVector, double) instead

### interpolate

    public final void interpolate(GVector v1,
                                  float alpha)

  Deprecated. Use interpolate(GVector, double) instead

### interpolate

    public final void interpolate(GVector v1,
                                  GVector v2,
                                  double alpha)

  Linearly interpolates between vectors v1 and v2 and places the result into this tuple: this = (1-alpha)*v1 + alpha*v2.

  Parameters:
    `v1` - the first vector
    `v2` - the second vector
    `alpha` - the alpha interpolation parameter

### interpolate

    public final void interpolate(GVector v1,
                                  double alpha)

  Linearly interpolates between this vector and vector v1 and places the result into this tuple: this = (1-alpha)*this + alpha*v1.

  Parameters:
    `v1` - the first vector
    `alpha` - the alpha interpolation parameter

### clone

    public java.lang.Object clone()

  Creates a new object of the same class as this object.

  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    a clone of this instance.
  Throws:
    `java.lang.OutOfMemoryError` - if there is not enough memory.
  Since:
    vecmath 1.3
  See Also:
    `Cloneable`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.