math
Class VectorOps

java.lang.Object
  extended by math.VectorOps

public class VectorOps
extends java.lang.Object

a class with vector operations


Constructor Summary
VectorOps()
           
 
Method Summary
static Vector3D createDiffuseVector(OrthonormalBasis uvw, Point2D p)
          creates a diffuse vector from a 2D random point
static Vector3D cross(Vector3D v1, Vector3D v2)
          returns the cross product of two vectors
static double dot(Vector3D v1, Vector3D v2)
          returns the scalar product of two vectors
static int indexOfMinAbsComponent(Vector3D v)
          Returns index of smallest component
static double magnitude(Vector3D v)
          returns the length of the vector
static Vector3D minus(Vector3D v1, Vector3D v2)
          subtracts the vector v2 from v1
static Vector3D normalize(Vector3D v)
          normalize a 3d vector
static double normalizeMag(Vector3D v)
          normalizes a vector and returns its length
static Vector3D perpendicular(Vector3D v)
          Returns a vector perpendicular to this one
static Vector3D perturb(Vector3D vec, double down, double around)
          perturbs the vector down and around
static Vector3D plus(Vector3D v1, Vector3D v2)
          adds two vectors
static Vector3D scale(double s, Vector3D v)
          scales the vector with the double s
static Point3D toPoint3D(Vector v)
          converts a 4-vector to a 3d-point
static Vector3D toVector3D(Vector v)
          converts a 4-vector to a 3-vector
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VectorOps

public VectorOps()
Method Detail

normalize

public static Vector3D normalize(Vector3D v)
normalize a 3d vector

Parameters:
v - [in] vector
Returns:
normalized v

dot

public static double dot(Vector3D v1,
                         Vector3D v2)
returns the scalar product of two vectors

Parameters:
v1 - [in] vector #1
v2 - [in] vector #2
Returns:
v1 dot v2

cross

public static Vector3D cross(Vector3D v1,
                             Vector3D v2)
returns the cross product of two vectors

Parameters:
v1 - [in] vector #1
v2 - [in] vector #2
Returns:
v1 cross v2

minus

public static Vector3D minus(Vector3D v1,
                             Vector3D v2)
subtracts the vector v2 from v1

Parameters:
v1 - [in] vector #1
v2 - [in] vector #2
Returns:
v1-v2

plus

public static Vector3D plus(Vector3D v1,
                            Vector3D v2)
adds two vectors

Parameters:
v1 - [in] vector #1
v2 - [in] vector #2
Returns:
v1+v2

scale

public static Vector3D scale(double s,
                             Vector3D v)
scales the vector with the double s

Parameters:
s - [in] s
v - [in] vector
Returns:
s*v

normalizeMag

public static double normalizeMag(Vector3D v)
normalizes a vector and returns its length

Parameters:
v - [in] vector
Returns:
length of v

magnitude

public static double magnitude(Vector3D v)
returns the length of the vector

Parameters:
v - [in] vector
Returns:
length of v

toVector3D

public static Vector3D toVector3D(Vector v)
converts a 4-vector to a 3-vector

Parameters:
v - [in] vector
Returns:
3-vector of v

toPoint3D

public static Point3D toPoint3D(Vector v)
converts a 4-vector to a 3d-point

Parameters:
v - [in] vector
Returns:
point of v

indexOfMinAbsComponent

public static int indexOfMinAbsComponent(Vector3D v)
Returns index of smallest component

Parameters:
v - [in] vector
Returns:
index of min(x,y,z)

perpendicular

public static Vector3D perpendicular(Vector3D v)
Returns a vector perpendicular to this one

Parameters:
v - [in] vector
Returns:
vector perpendicular to v

createDiffuseVector

public static Vector3D createDiffuseVector(OrthonormalBasis uvw,
                                           Point2D p)
creates a diffuse vector from a 2D random point

Parameters:
uvw - [in] onb
p - [in] 2d-point

perturb

public static Vector3D perturb(Vector3D vec,
                               double down,
                               double around)
perturbs the vector down and around

Parameters:
vec - [in] vector
down -
around -