public class Vector3D
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
Constructor and Description |
---|
Vector3D()
Creates a new Vector3D with defaults of X,Y,Z = 1.0 and W = 0.0.
|
Vector3D(double x,
double y,
double z)
Creates a new Vector3D with the specified x,y,z values; that is, a vector
from the origin to (x,y,x).
|
Vector3D(double x,
double y,
double z,
double w)
Creates a new Vector3D with the specified x,y,z, and w values; that is, a
vector from the origin to (x,y,z) and containing the specified w
component.
|
Vector3D(Point3D aPoint)
Creates a new Vector3D implied by the X,Y,Z values of the specified
Point3D; that is, a vector from the origin to the specified point.
|
Vector3D(Vertex3D aVertex)
Creates a new Vector3D implied by the location of the specified Vertex3D;
that is, a vector from the origin to the specified vertex's location.
|
Modifier and Type | Method and Description |
---|---|
Vector3D |
add(Vector3D v2)
Returns a new Vector3D whose X,Y,Z values are the sum of this Vector's
values and the specified Vector's values.
|
java.lang.Object |
clone()
Returns a new Vector3D which is a deep clone of this Vector3D.
|
Vector3D |
cross(Vector3D v)
Returns a new Vector3D which is the cross product of this vector with the
specified vector.
|
Vector3D |
div(double theDivisor)
Returns a new Vector3D which is the result of dividing this vector by the
specified divisor; that is, a scaled copy of this vector.
|
double |
dot(Vector3D v)
Returns the value of the "dot product" of this Vector with and the
specified vector.
|
boolean |
equals(Vector3D other)
|
double |
getW()
Returns the W component of this Vector3D object.
|
double |
getX()
Returns the X component of this Vector3D object.
|
double |
getY()
Returns the Y component of this Vector3D object.
|
double |
getZ()
Returns the Z component of this Vector3D object.
|
void |
interpolate(Vector3D finalVec,
float changeAmnt)
Sets this
Vector3D to the interpolation by changeAmnt from this to the
the specified finalVec; that is, changes the values in this Vector3D as
follows: |
double |
magnitude()
Returns the magnitude (length) of this vector.
|
Vector3D |
minus(Vector3D v2)
Returns a new Vector3D whose X,Y,Z values are the difference between this
Vector's X,Y,Z and the specified Vector's X,Y,Z.
|
Vector3D |
mult(double theMultiplier)
Returns a new Vector3D which is the result of multiplying this vector by
the specified multiplier; that is, a scaled copy of this vector.
|
Vector3D |
mult(Matrix3D mat)
Returns a new Vector3D which is the result of multiplying this Vector by
the given matrix.
|
Vector3D |
normalize()
Returns a new Vector3D with the same direction as this vector but with a
length of 1.
|
void |
scale(double scaleFactor)
Scales each of the X, Y, and Z components of this Vector by the given
scaleFactor.
|
void |
setW(double newW)
Sets the W component of this Vector3D object.
|
void |
setX(double newX)
Sets the X component of this Vector3D object.
|
void |
setY(double newY)
Sets the Y component of this Vector3D object.
|
void |
setZ(double newZ)
Sets the Z component of this Vector3D object.
|
java.lang.String |
toString()
Returns a printable representation of this Vector3D.
|
public Vector3D()
public Vector3D(double x, double y, double z)
public Vector3D(double x, double y, double z, double w)
public Vector3D(Point3D aPoint)
public Vector3D(Vertex3D aVertex)
public double getX()
public double getY()
public double getZ()
public double getW()
public void setX(double newX)
public void setY(double newY)
public void setZ(double newZ)
public void setW(double newW)
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(Vector3D other)
public Vector3D minus(Vector3D v2)
public Vector3D add(Vector3D v2)
public Vector3D mult(double theMultiplier)
public Vector3D div(double theDivisor)
public double magnitude()
public Vector3D normalize()
public Vector3D mult(Matrix3D mat)
public void scale(double scaleFactor)
public double dot(Vector3D v)
public Vector3D cross(Vector3D v)
public void interpolate(Vector3D finalVec, float changeAmnt)
Vector3D
to the interpolation by changeAmnt from this to the
the specified finalVec; that is, changes the values in this Vector3D
as
follows:
this=(1-changeAmnt)*this + (changeAmnt * finalVec)
Only the X, Y, and Z components of this Vector3D
are changed; the W
component is not affected.
finalVec
- The final vector to interpolate towardschangeAmnt
- An amount between 0.0 - 1.0 representing a precentage
change from this towards finalVecpublic java.lang.String toString()
toString
in class java.lang.Object