de.jreality.tutorial.projects.ksurfaces
Class R3

java.lang.Object
  extended by de.jreality.tutorial.projects.ksurfaces.R3

public class R3
extends Object

This class provides simple static methods to do verctor calculation in R3. The vectors of R3 are represented by array of 3 doubles.


Constructor Summary
R3()
           
 
Method Summary
static void copy(double[] a, double[] target)
          target = a, copy the entries of a into target
static void cross(double[] a, double[] b, double[] target)
          target = a x b, i.e., the cross product or vector product
WARNING: This method fails when the target is same as one of its arguments.
static double dot(double[] a, double[] b)
          <a,b>, i.e., the dot product or inner product
static void minus(double[] a, double[] b, double[] target)
          target = a-b
static double norm(double[] a)
          |a|, the length of a vector.
static double normSquared(double[] a)
          |a|^2, the square of the length of a vector.
static void plus(double[] a, double[] b, double[] target)
          target = a + b
static void times(double s, double[] a, double[] target)
          target = s * a, product of a real with a vector
static void zero(double[] target)
          target = 0, reset the three entries of target to 0
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

R3

public R3()
Method Detail

plus

public static final void plus(double[] a,
                              double[] b,
                              double[] target)
target = a + b

Parameters:
a - array of 3 doubles
b - array of 3 doubles
target - array of 3 doubles

minus

public static final void minus(double[] a,
                               double[] b,
                               double[] target)
target = a-b

Parameters:
a - array of 3 doubles
b - array of 3 doubles
target - array of 3 doubles

cross

public static final void cross(double[] a,
                               double[] b,
                               double[] target)
target = a x b, i.e., the cross product or vector product
WARNING: This method fails when the target is same as one of its arguments.

Parameters:
a - array of 3 doubles
b - array of 3 doubles
target - array of 3 doubles

copy

public static final void copy(double[] a,
                              double[] target)
target = a, copy the entries of a into target

Parameters:
a - array of 3 doubles
target - array of 3 doubles

zero

public static final void zero(double[] target)
target = 0, reset the three entries of target to 0

Parameters:
target - array of 3 doubles

dot

public static final double dot(double[] a,
                               double[] b)
<a,b>, i.e., the dot product or inner product

Parameters:
a - array of 3 doubles
b - array of 3 doubles
Returns:
the value of the dot product

times

public static final void times(double s,
                               double[] a,
                               double[] target)
target = s * a, product of a real with a vector

Parameters:
s - the scalar real
a - array of 3 doubles
target - array of 3 doubles

norm

public static double norm(double[] a)
|a|, the length of a vector.

Parameters:
a - array of 3 doubles
Returns:
the length of a

normSquared

public static double normSquared(double[] a)
|a|^2, the square of the length of a vector.

Parameters:
a - array of 3 doubles
Returns:
the square of the length of a