|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Vector
Vector stores and manipulates xyz triples representing 3 space vectors.
Field Summary | |
double |
X
Holds the X component |
double |
Y
Holds the Y component |
double |
Z
Holds the Z component |
Constructor Summary | |
Vector()
Create a new vector and set it to zero |
|
Vector(double x,
double y,
double z)
Create a new vector with the given x,y and z values |
|
Vector(Point p)
Create a new vector by converting a Point object |
|
Vector(Vector v)
Create a new vector by copying an existing vector |
Method Summary | |
void |
add(Vector v)
Add the given vector to this vector |
static Vector |
add(Vector v1,
Vector v2)
Static function to sum two vector and write it to a given destination vector. |
static void |
add(Vector vd,
Vector v1,
Vector v2)
Static function to sum two vectors and write it to a given destination vector. |
void |
copy(Vector v)
Copy an existing vector to this vector |
void |
cross(Vector v)
Cross product the given vector with this vector |
static Vector |
cross(Vector v1,
Vector v2)
Static cross product methods that creates a new vector with the cross product of the two given vectors. |
static void |
cross(Vector vd,
Vector v1,
Vector v2)
Static cross product methods that write the cross product of the two given vectors to the given desination vector. |
double |
dot(Point p)
Dot product the given vector with a point |
double |
dot(Vector v)
Dot product the given vector with this vector |
static double |
dot(Vector v1,
Vector v2)
Static method that returns the dot product of the two given * vectors. |
void |
negate()
Negate this vector |
static Vector |
negate(Vector v)
Static negate method that creates a new vector from a given vector. |
double |
norm()
Find the length of this vector |
void |
normalise()
Normalise this vector |
Vector |
normalised()
Create a new vector as the normalisation of this vector |
void |
print(SceneWriter os)
Print a human readable version of the vector definition to the given destination |
void |
read(SceneReader is)
Read the vector from the given source |
void |
scale(double s)
Scale this vector by the given factor |
static Vector |
scale(Vector v,
double s)
Static scale method that creates a new vector from a given vector and scale factor. |
static void |
scale(Vector vd,
Vector v,
double s)
Static scale method that writes a scaled vector based upon the given vector and scale factor. |
void |
set(double x,
double y,
double z)
Set this vector to the given x,y and z values |
double |
squarednorm()
Find the squared length of this vector |
static Vector |
subtract(Point p1,
Point p2)
Static function to create a new vector as the difference between two points. |
void |
subtract(Vector v)
Subtract the given vector from this vector |
static void |
subtract(Vector v,
Point p1,
Point p2)
Static function to find the difference between two points and write it to a given destination vector. |
static Vector |
subtract(Vector v1,
Vector v2)
Static function to create a new vector as the difference between two vectors. |
static void |
subtract(Vector vd,
Vector v1,
Vector v2)
Static function to find the difference between two vectors and write it to a given destination vector. |
java.lang.String |
toString()
|
void |
write(SceneWriter os)
Write the vector to the given destination |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public double X
public double Y
public double Z
Constructor Detail |
public Vector()
public Vector(double x, double y, double z)
x
- the x valuey
- the y valuez
- the z valuepublic Vector(Vector v)
v
- the vector to copypublic Vector(Point p)
p
- the point to copyMethod Detail |
public void set(double x, double y, double z)
x
- the x valuey
- the y valuez
- the z valuepublic void copy(Vector v)
v
- the vector to copypublic double squarednorm()
public double norm()
public void normalise()
public Vector normalised()
public static Vector subtract(Point p1, Point p2)
p1
- the first pointp2
- the second point
public static void subtract(Vector v, Point p1, Point p2)
v
- the destination vectorp1
- the first pointp2
- the second point
public void subtract(Vector v)
v
- the vector to subtractpublic static Vector subtract(Vector v1, Vector v2)
v1
- the first vectorv2
- the second vector
public static void subtract(Vector vd, Vector v1, Vector v2)
vd
- the destination vectorv1
- the first vectorv2
- the second vectorpublic void add(Vector v)
v
- the vector to addpublic static Vector add(Vector v1, Vector v2)
v1
- the first vectorv2
- the second vector
public static void add(Vector vd, Vector v1, Vector v2)
vd
- the destination vectorv1
- the first vectorv2
- the second vectorpublic void cross(Vector v)
v
- the vector to cross withpublic static Vector cross(Vector v1, Vector v2)
v1
- the first vector to cross withv2
- the second vector to cross with
public static void cross(Vector vd, Vector v1, Vector v2)
vd
- the vector to store the cross product inv1
- the first vector to cross withv2
- the second vector to cross withpublic double dot(Vector v)
v
- the vector to dot product with
public double dot(Point p)
p
- the point to dot product with
public static double dot(Vector v1, Vector v2)
v1
- the first vector of the dot productv2
- the second vector of the dot product
public void scale(double s)
s
- the scale factorpublic static Vector scale(Vector v, double s)
v
- the vector to scales
- the scale factor
public static void scale(Vector vd, Vector v, double s)
vd
- the destination vectorv
- the vector to scales
- the scale factorpublic void negate()
public static Vector negate(Vector v)
v
- the vector to negate
public void read(SceneReader is) throws java.io.IOException, java.lang.NumberFormatException
is
- the source to read from
java.io.IOException
- if the light can not be read
java.io.NumberFormatException
- if there a number format error is encountered
java.lang.NumberFormatException
public void write(SceneWriter os) throws java.io.IOException
os
- the destination to write to
java.io.IOException
- if the write fails.public void print(SceneWriter os) throws java.io.IOException
os
- the destination to write to
java.io.IOException
- if the write fails.public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |