|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectrender.Vec
Provides functionality to manipulate vectors.
| Constructor Summary | |
Vec()
|
|
| Method Summary | |
static void |
capLength(double[] vector,
double maxLength)
If vector's length is greater than maxLength, reduces it to that. |
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 |
distance(double[] a,
double[] b,
double[] difference)
|
static double |
dot(double[] a,
double[] b)
Computes the dot product of vectors a and b. |
static boolean |
equals(double[] a,
double[] b)
|
static double |
length(double[] vector)
|
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 |
scale(double[] vector,
double length)
Resizes vector to given length |
static void |
set(double[] dst,
double x,
double y,
double z)
Populates the dst vector with values x, y, z. |
static void |
zero(double[] a)
Set all the entries to 0 |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Vec()
| Method Detail |
public static void normalize(double[] v)
v - a vectorpublic static double norm(double[] v)
v - a vector
public static double dot(double[] a,
double[] b)
a - source vectorb - source vector
public static void cross(double[] a,
double[] b,
double[] dst)
a - source vector 1b - source vector 2dst - resulting vector from a cross b
public static void copy(double[] src,
double[] dst)
src - original vectordst - copy of original vector
public static boolean equals(double[] a,
double[] b)
public static void set(double[] dst,
double x,
double y,
double z)
dst - vector to be populatedx - component 0y - component 1z - component 2
public static void rotate(double[] dst,
int axis,
double angle)
dst - vector to be rotatedaxis - of rotation: 0=x, 1=y, 2=zangle - in radians
public static void capLength(double[] vector,
double maxLength)
vector - vector to resizemaxLength - if vector is longer than this, resizes it to this.
public static void scale(double[] vector,
double length)
vector - vector to resizelength - desired lengthpublic static double length(double[] vector)
public static void zero(double[] a)
public static double distance(double[] a,
double[] b,
double[] difference)
difference - a temp array of the same size as a and b to work with (its
contents will be modified). This can be null, which will cause the
code to dynamically allocate an array to be used.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||