|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vmm.core3D.Vector3D
public class Vector3D
A 3D vector with components of type double named x, y, and z.
Field Summary | |
---|---|
static Vector3D |
ORIGIN
The origin, (0,0,0). |
static Vector3D |
UNIT_X
The unit vector in the x direction, (1,0,0). |
static Vector3D |
UNIT_Y
The unit vector in the y direction, (0,1,0). |
static Vector3D |
UNIT_Z
The uint vector in the z direction, (0,0,1). |
double |
x
The first component of the vector. |
double |
y
The second component of the vector. |
double |
z
The third component of the vector. |
Constructor Summary | |
---|---|
Vector3D()
Construct a vector with all three components initially equal to zero. |
|
Vector3D(double x,
double y,
double z)
Construct a vector that initially has coordinates (x,y,z). |
|
Vector3D(Vector3D v)
Construct a vector that is initially a copy of a specified vector. |
Method Summary | |
---|---|
void |
assign(Vector3D v)
this.assign(v) assigns to this the value v. |
void |
assignLinComb(double c,
double d,
Vector3D v)
this.assignLinComb(c,d,v) assigns to this the value c*this + d*v. |
void |
assignLinComb(double c,
Vector3D v,
double d,
Vector3D w)
this.assignLinComb(c,v,d,w) assigns to this the value c*v + d*w. |
void |
assignMinus(Vector3D v)
this.assignMinus(v) assigns to this the value this (- v). |
void |
assignMinus(Vector3D v,
Vector3D w)
this.assignMinus(v, w) assigns to this the value this (v - w). |
void |
assignPlus_SumTimes(Vector3D u,
Vector3D v,
Vector3D w,
Vector3D ww,
double d)
this.assignPlus_SumTimes(u, v, w, ww, d) assigns to this the value: this + (u + v + w + ww)*d. |
void |
assignPlus(Vector3D v)
this.assignPlus(v) assigns to this the value this + v. |
void |
assignSum(Vector3D v,
Vector3D w)
this.assignSum(v,w) assigns to this the value v + w. |
void |
assignSumTimes(Vector3D v,
Vector3D w,
double d)
this.assignSumTimes(v, w, d) assigns to this the value (v + w)*d. |
void |
assignSumTimes(Vector3D v,
Vector3D w,
Vector3D vv,
Vector3D ww,
double d)
this.assignSumTimes(v, w, vv, ww, d) assigns to this the value (v + w + vv + ww)*d. |
void |
assignTimes(double d)
this.assignTimes(d) assigns to this the value d*this. |
void |
assignTimes(double d,
Vector3D v)
this.assignTimes(d, v) assigns to this the value d*v. |
Vector3D |
cross(Vector3D v)
Returns the cross product of this vector and v. |
double |
dot(Vector3D v)
Returns the dot product of this vector and v. |
boolean |
equals(java.lang.Object obj)
Returns true obj is a non-null object whose class in Vector3D and such that
the three corrdinates of the vector obj are the same as the coordinates of this
vector. |
static Vector3D |
fromString(java.lang.String str)
Attempts to convert a string into a value of type Vector3D. |
Vector3D |
linComb(double c,
double d,
Vector3D v)
Returns the linear combination c*this + d*v. |
Vector3D |
minus(Vector3D v)
Returns the vector difference of this vector and v. |
void |
negate()
Multiplies each component of this vector by -1. |
Vector3D |
negated()
Returns a new vector that is equal to -1 times this vector. |
double |
norm()
Returns the length of this vector, computed as Math.sqrt(x*x+y*y+z*z) |
double |
norm2()
Returns the length^2 of this vector, computed as (x*x+y*y+z*z) |
void |
normalize()
Divides each component of the vector by the norm of the vector, giving a vector that has length 1. |
Vector3D |
normalized()
Returns a new vector that is equal to this vector normalized. |
Vector3D |
plus(Vector3D v)
Returns the vector sum of this vector and v. |
Vector3D |
reflectInAxis(Vector3D axis)
Rotates this around the unit vector axis by 180 degrees: this to -this + 2 |
Vector3D |
times(double d)
Returns the scalar product of this vector times d. |
java.lang.String |
toString()
Returns a string representation of this vector of the form "(x,y,z)" where x, y, and z are the numerical components of the vector. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public double x
public double y
public double z
public static final Vector3D ORIGIN
public static final Vector3D UNIT_X
public static final Vector3D UNIT_Y
public static final Vector3D UNIT_Z
Constructor Detail |
---|
public Vector3D()
public Vector3D(double x, double y, double z)
public Vector3D(Vector3D v)
v
- the constructed vector is (v.x, v.y, v.z), or is (0,0,0) if v is null.Method Detail |
---|
public boolean equals(java.lang.Object obj)
obj
is a non-null object whose class in Vector3D and such that
the three corrdinates of the vector obj
are the same as the coordinates of this
vector.
equals
in class java.lang.Object
public double norm()
Math.sqrt(x*x+y*y+z*z)
public double norm2()
(x*x+y*y+z*z)
public void normalize()
normalized()
public void negate()
negated()
public Vector3D normalized()
normalize()
public Vector3D negated()
negate()
public Vector3D plus(Vector3D v)
v
- a non-null vectorpublic Vector3D linComb(double c, double d, Vector3D v)
public void assign(Vector3D v)
public void assignPlus(Vector3D v)
public void assignSum(Vector3D v, Vector3D w)
public void assignLinComb(double c, double d, Vector3D v)
public void assignLinComb(double c, Vector3D v, double d, Vector3D w)
public void assignPlus_SumTimes(Vector3D u, Vector3D v, Vector3D w, Vector3D ww, double d)
public Vector3D minus(Vector3D v)
v
- a non-null vectorpublic void assignMinus(Vector3D v)
public void assignMinus(Vector3D v, Vector3D w)
public Vector3D times(double d)
d
- the scalar that is to be multiplied times this vectorpublic void assignTimes(double d)
public void assignTimes(double d, Vector3D v)
public void assignSumTimes(Vector3D v, Vector3D w, double d)
public void assignSumTimes(Vector3D v, Vector3D w, Vector3D vv, Vector3D ww, double d)
public double dot(Vector3D v)
v
- a non-null vectorpublic Vector3D cross(Vector3D v)
v
- a non-null vectorpublic Vector3D reflectInAxis(Vector3D axis)
public java.lang.String toString()
toString
in class java.lang.Object
public static Vector3D fromString(java.lang.String str) throws java.lang.NumberFormatException
toString()
, of the form "(x,y,z)". Will also accept strings
that use a space as a separator and are not enclosed in parentheses, of the form "x y z".
str
- the non-null string that is to be converted
java.lang.NumberFormatException
- if the string is not of the correct format (or is null)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |