public class Vector
extends java.lang.Object
implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
double |
x
x coordinate
|
double |
y
y coordinate
|
double |
z
z coordinate
|
Constructor and Description |
---|
Vector()
Creates a new instance of Vector
|
Vector(double _x,
double _y,
double _z)
Creates a new instance of Vector
|
Vector(Vector v)
Creates a new instance of Vector
|
Modifier and Type | Method and Description |
---|---|
void |
add(double _x,
double _y,
double _z)
Add a triplet (x/y/z) to us
|
void |
add(Vector v)
Add another vector to ours.
|
Vector |
append(Vector ov)
return the results of us+them (doens't modify us)
|
protected java.lang.Object |
clone()
clone this vector.
|
void |
divide(double d)
Divide our vector by a double
|
boolean |
equals(Vector p)
Return whether two Vectors are equal
|
boolean |
isZero()
Return whether this Vector is zero
|
void |
multiply(double d)
Multiply our vector by a double
|
void |
multiply(Vector v)
Multiply our vector by another vector
|
Vector |
reduce(Vector ov)
return the results of us-them (doens't modify us)
|
void |
rotateDegrees(Vector vec)
rotate this vector around the origin by the vector passed.
|
void |
rotateRadians(Vector vec) |
void |
set(double d)
Set each of this Vector's components to the value passed
|
void |
set(double _x,
double _y,
double _z)
Set this Vector to be the value of the x/y/z passed in
|
void |
set(Vector v)
Set this Vector to be the same as the Vector passed in
|
void |
setVlength(double len)
Set the length of this vector.
|
void |
setZero()
Set our Vector to be 0,0,0
|
void |
subtract(Vector v)
Subtract another vector from ours.
|
java.lang.String |
toDegreesString()
return this vector as a POV-Ray vector string expressed in degrees
|
java.lang.String |
toString()
return a POV-Ray compatible string of this vector.
|
double |
vlength()
return the length of the 3-D vector
|
public double x
public double y
public double z
public Vector()
public Vector(double _x, double _y, double _z)
_x
- The x coordinate of the new Vector_y
- The y coordinate of the new Vector_z
- The z coordinate of the new Vectorpublic Vector(Vector v)
v
- The vector to initialize our coordinates fromprotected java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- Whateverpublic boolean equals(Vector p)
public boolean isZero()
public void setZero()
public void set(Vector v)
public void set(double _x, double _y, double _z)
public void set(double d)
public Vector append(Vector ov)
ov
- The other vector to addpublic void add(Vector v)
v
- The other vector.public void add(double _x, double _y, double _z)
public void subtract(Vector v)
v
- The other vector.public Vector reduce(Vector ov)
ov
- The other vector to subtractpublic void multiply(double d)
d
- The amount to multiply each of our x,y,z coordinates by.public void multiply(Vector v)
v
- The amount to multiply each of our x,y,z coordinates by.public void divide(double d)
d
- The amount to divide each of our x,y,z coordinates by.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toDegreesString()
public double vlength()
public void setVlength(double len)
len
- The length to set this vector to.public void rotateDegrees(Vector vec)
vec
- The vector, expressed in degrees of the rotation. i.e. 0,180,90public void rotateRadians(Vector vec)