render
Class Vec

java.lang.Object
  |
  +--render.Vec

public class Vec
extends java.lang.Object

Provides functionality to manipulate vectors.


Constructor Summary
Vec()
           
 
Method Summary
static void copy(double[] src, double[] dst)
          Copies contents of the src vector to the dst vector.
static void cross(double[] a, double[] b, double[] dst)
          Computes the cross-product of two vectors a and b and stores the result in dst.
static double dot(double[] a, double[] b)
          Computes the dot product of vectors a and b.
static double norm(double[] v)
          Computes the magnitude of the vector.
static void normalize(double[] v)
          Normalizes vector v to unit-length.
static void rotate(double[] dst, int axis, double angle)
          Rotates a vector about x or y or z axis
static void set(double[] dst, double x, double y, double z)
          Populates the dst vector with values x, y, z.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vec

public Vec()
Method Detail

normalize

public static void normalize(double[] v)
Normalizes vector v to unit-length.

Parameters:
v - a vector

norm

public static double norm(double[] v)
Computes the magnitude of the vector.

Parameters:
v - a vector
Returns:
the magnitude of vector v

dot

public static double dot(double[] a,
                         double[] b)
Computes the dot product of vectors a and b. Vectors a and b must be of the same length.

Parameters:
a - source vector
b - source vector
Returns:
the result of a dot b

cross

public static void cross(double[] a,
                         double[] b,
                         double[] dst)
Computes the cross-product of two vectors a and b and stores the result in dst. a, b, and dst must be 3 dimensional vectors.

Parameters:
a - source vector 1
b - source vector 2
dst - resulting vector from a cross b

copy

public static void copy(double[] src,
                        double[] dst)
Copies contents of the src vector to the dst vector. Both vectors must be of the same length.

Parameters:
src - original vector
dst - copy of original vector

set

public static void set(double[] dst,
                       double x,
                       double y,
                       double z)
Populates the dst vector with values x, y, z.

Parameters:
dst - vector to be populated
x - component 0
y - component 1
z - component 2

rotate

public static void rotate(double[] dst,
                          int axis,
                          double angle)
Rotates a vector about x or y or z axis

Parameters:
dst - vector to be rotated
axis - of rotation: 0=x, 1=y, 2=z
angle - in radians