|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--SpaceVector
Implementation of representation of a vector in space; that is, a component vector in the three dimensional rectangular coordinate system. This class provides the basic operations of constant vectors for the simplification of all problems to which it applies.
| Constructor Summary | |
SpaceVector(double x,
double y,
double z)
Creates a new SpaceVector from the
specified doubles. |
|
SpaceVector(float x,
float y,
float z)
Creates a new SpaceVector. |
|
| Method Summary | |
void |
add(SpaceVector sv)
Sets the value of this SpaceVector to the
sum of this + the argument sv. |
float |
angleBetween(SpaceVector sv)
Returns the angle between this SpaceVector and the
argument SpaceVector sv. |
java.lang.Object |
clone()
Returns an exact clone of this SpaceVector. |
float |
cosBetween(SpaceVector sv)
Returns the value of cos(theta) where cos(theta) = (u · v)/(||u|| ||v||). |
float |
dot(SpaceVector sv)
Returns the dot product of this SpaceVector and the
specified SpaceVectorsv. |
static boolean |
equal(double d1,
double d2)
Determines whether two doubles are close enough
together to be considered equal. |
static boolean |
equal(float f1,
float f2)
Determines whether two floats are close enough
together to be considered equal. |
boolean |
equals(float X,
float Y,
float Z)
Determines if this vector is equal to the corresponding vector defined by the x, y, z coordinates. |
boolean |
equals(java.lang.Object o)
Determines whether the Object parameter is equal to this
SpaceVector or not. |
boolean |
equals(SpaceVector sv)
Determines whether the vector is equivalent to the specified SpaceVector argument. |
SpaceVector |
getCrossProduct(SpaceVector sv)
Returns the SpaceVector representation of the
cross product given by this SpaceVector
× the argument SpaceVector. |
SpaceVector |
getMultiple(float c)
Returns a new SpaceVector which has been
scaled by the float c. |
SpaceVector |
getNegation()
Returns a negated version of this SpaceVector. |
SpaceVector |
getOrthogonalComponentOf(SpaceVector sv)
Returns the vector component of this orthogonal to the argument sv. |
SpaceVector |
getProjectionOnto(SpaceVector sv)
Returns the projection of this SpaceVector
onto the SpaceVector sv. |
SpaceVector |
getSum(SpaceVector sv)
Returns a new SpaceVector representing the sum
of this SpaceVector with the argument SpaceVector
sv. |
SpaceVector |
getUnitVector()
Returns the unit vector version of this SpaceVector. |
float |
getX()
Returns the x-component of the SpaceVector. |
float |
getY()
Returns the y-component of the SpaceVector. |
float |
getZ()
Returns the z-component of the SpaceVector. |
int |
hashCode()
Returns a hashcode for this SpaceVector object. |
boolean |
isOrthogonal(SpaceVector sv)
Determines if this SpaceVector is orthogonal to the
specified SpaceVector sv. |
boolean |
isParallel(SpaceVector sv)
Determines if the specified SpaceVector sv is parallel with
this SpaceVector. |
boolean |
isUnitVector()
Duhhhhh... |
boolean |
isZeroVector()
Determines whether this is the zero vector 0. |
float |
magnitude()
Returns the magnitude ||this|| of this SpaceVector. |
static double |
magnitude(double x,
double y,
double z)
Returns the magnitude of the given x, y, and z values of the specified vector in space <x, y, z>. |
static float |
magnitude(float x,
float y,
float z)
Returns the magnitude of the given x, y, and z values of the specified vector in space <x, y, z>. |
void |
multiply(double c)
Scales this SpaceVector to the scalar double c. |
void |
multiply(float c)
Scales this SpaceVector to the scalar float c. |
void |
negate()
Sets this SpaceVector's value to the opposite direction. |
void |
paintArrow(float initialX,
float initialY,
float initialZ,
int centX,
int centY,
int screenDistance,
float arrowSize,
java.awt.Color color,
java.awt.Graphics g)
|
void |
paintLine(float initialX,
float initialY,
float initialZ,
int centX,
int centY,
java.awt.Color color,
java.awt.Graphics g)
|
void |
projectOnto(SpaceVector sv)
Sets this SpaceVector equal to the projection of itself
onto the SpaceVector argument sv denoted by
projthissv. |
void |
rotateAbout(double arx,
double ary,
double arz,
double theta)
Rotates this SpaceVector theta radians about
the line <arx, ary, arz>. |
void |
rotateAbout(float arx,
float ary,
float arz,
float theta)
Rotates this SpaceVector theta radians about
the line <arx, ary, arz>. |
void |
rotateAbout(SpaceVector sv,
double theta)
Rotates this SpaceVector theta radians about
the line denoted by the SpaceVector sv. |
void |
rotateAbout(SpaceVector sv,
float theta)
Rotates this SpaceVector theta radians about
the line denoted by the SpaceVector sv. |
void |
rotateX(float theta)
Rotates this SpaceVector theta radians about
the x-axis. |
void |
rotateY(float theta)
Rotates this SpaceVector theta radians about
the y-axis. |
void |
rotateZ(float theta)
Rotates this SpaceVector theta radians about
the z-axis. |
void |
setX(double x)
Sets the x-component to the specified value. |
void |
setX(float x)
Sets the x-component to the specified value. |
void |
setY(double y)
Sets the y-component to the specified value. |
void |
setY(float y)
Sets the y-component to the specified value. |
void |
setZ(double z)
Sets the z-component to the specified value. |
void |
setZ(float z)
Sets the z-component to the specified value. |
void |
subtract(SpaceVector sv)
Same as the add method except sv is
negative. |
void |
toCrossProduct(SpaceVector sv)
Sets this SpaceVector equal to the
cross product given by this SpaceVector × the
argument SpaceVector. |
void |
toOrthogonalComponentOf(SpaceVector sv)
Sets this SpaceVector to be the vector component of this orthogonal to the argument
sv. |
java.lang.String |
toString()
Returns a String representation of this SpaceVector
object. |
void |
toUnitVector()
Sets the value of this SpaceVector to its
equivalent unit vector. |
float |
xCos()
Returns the direction cosine between this SpaceVector
and the x-axis. |
float |
yCos()
Returns the direction cosine between this SpaceVector
and the y-axis. |
float |
zCos()
Returns the direction cosine between this SpaceVector
and the z-axis. |
| Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public SpaceVector(float x,
float y,
float z)
SpaceVector.
public SpaceVector(double x,
double y,
double z)
SpaceVector from the
specified doubles. The coordinates
will be transformes to floats. All
operations are done internally on four byte
floats.| Method Detail |
public final float getX()
SpaceVector.public final float getY()
SpaceVector.public final float getZ()
SpaceVector.public final void setX(float x)
public final void setY(float y)
public final void setZ(float z)
public final void setX(double x)
double
is internally converted to a float
before any assignments are made.public final void setY(double y)
double
is internally converted to a float
before any assignments are made.public final void setZ(double z)
double
is internally converted to a float
before any assignments are made.public final void add(SpaceVector sv)
SpaceVector to the
sum of this + the argument sv.getSum(SpaceVector sv)public final void subtract(SpaceVector sv)
add method except sv is
negative.public final SpaceVector getSum(SpaceVector sv)
SpaceVector representing the sum
of this SpaceVector with the argument SpaceVector
sv. Does not change the value of this SpaceVector.add(SpaceVector sv)public final void multiply(float c)
SpaceVector to the scalar float c.public final void multiply(double c)
SpaceVector to the scalar double c.public final SpaceVector getMultiple(float c)
SpaceVector which has been
scaled by the float c. Does not change the
value of this SpaceVector.SpaceVector.public final void negate()
SpaceVector's value to the opposite direction.getNegation()public final SpaceVector getNegation()
SpaceVector.
Does not change the value of this SpaceVector.negate()public final SpaceVector getUnitVector()
SpaceVector.
Does not change the value of this SpaceVector.toUnitVector()public final void toUnitVector()
SpaceVector to its
equivalent unit vector.getUnitVector()public final boolean isUnitVector()
public final float magnitude()
SpaceVector.
Every time this method is called, the magnitude is recalculated by
(float)Math.sqrt( x*x + y*y + z*z );
public static final float magnitude(float x,
float y,
float z)
x - the x component of the specified vector.y - the y component of the specified vector.z - the z component of the specified vector.
public static final double magnitude(double x,
double y,
double z)
x - the x component of the specified vector.y - the y component of the specified vector.z - the z component of the specified vector.public final boolean isParallel(SpaceVector sv)
SpaceVector sv is parallel with
this SpaceVector.true if this = csv.
otherwize false.public final boolean isZeroVector()
public final float dot(SpaceVector sv)
SpaceVector and the
specified SpaceVectorsv.
Definition of Dot Product
The dot product of u = <u1, u2,
u3 > and v = < v1,
v2, v3 > is
u · v = u1v1
+ u2v2 + u3v3.
Properties of the Dot Product
public final float angleBetween(SpaceVector sv)
SpaceVector and the
argument SpaceVector sv. The value is found from
theta = acos( (u · v)/(||u|| ||v||) ).
Returns the value of theta.public final float cosBetween(SpaceVector sv)
public final boolean isOrthogonal(SpaceVector sv)
SpaceVector is orthogonal to the
specified SpaceVector sv. In other words, returns
true iff this · sv = 0, otherwize false.public final float xCos()
SpaceVector
and the x-axis.public final float yCos()
SpaceVector
and the y-axis.public final float zCos()
SpaceVector
and the z-axis.public final void rotateX(float theta)
SpaceVector theta radians about
the x-axis.public final void rotateY(float theta)
SpaceVector theta radians about
the y-axis.public final void rotateZ(float theta)
SpaceVector theta radians about
the z-axis.
public final void rotateAbout(float arx,
float ary,
float arz,
float theta)
SpaceVector theta radians about
the line <arx, ary, arz>.
public final void rotateAbout(double arx,
double ary,
double arz,
double theta)
SpaceVector theta radians about
the line <arx, ary, arz>.
public final void rotateAbout(SpaceVector sv,
float theta)
SpaceVector theta radians about
the line denoted by the SpaceVector sv.
public final void rotateAbout(SpaceVector sv,
double theta)
SpaceVector theta radians about
the line denoted by the SpaceVector sv.public final void projectOnto(SpaceVector sv)
SpaceVector equal to the projection of itself
onto the SpaceVector argument sv denoted by
projthissv.getProjectionOnto(SpaceVector sv)public final SpaceVector getProjectionOnto(SpaceVector sv)
SpaceVector
onto the SpaceVector sv.projectOnto(SpaceVector sv)public final void toOrthogonalComponentOf(SpaceVector sv)
SpaceVector to be the vector component of this orthogonal to the argument
sv. Equal to this - projsvthis.sv - the SpaceVector which this SpaceVector
is projected onto.getOrthogonalComponentOf(SpaceVector sv)public final SpaceVector getOrthogonalComponentOf(SpaceVector sv)
sv - the SpaceVector which this SpaceVector
is projected onto.SpaceVector representing the vector component
of this SpaceVector to sv.toOrthogonalComponentOf(SpaceVector sv)public final SpaceVector getCrossProduct(SpaceVector sv)
SpaceVector representation of the
cross product given by this SpaceVector
× the argument SpaceVector.
Definition of Cross Product of Two Vectors in Space
Let u = u1i + u2j + u3k
and v = v1i + v2j + v3k.
The cross product of u and v is the vector
u × v =
( u2v3
- u3v2)i
- (u1v3
- u3v1)j
+ (u1v2
- u2v1)k.
Algebraic Properties of the Cross Product
Geometric Properties of the Cross Product
sv - The SpaceVector being crossed with this SpaceVector.SpaceVector of the cross product this × sv.toCrossProduct(SpaceVector sv)public final void toCrossProduct(SpaceVector sv)
SpaceVector equal to the
cross product given by this SpaceVector × the
argument SpaceVector. A table of algebraic and
geometric properties are given in the documentation on the
getCrossProduct(SpaceVector sv) method.the - SpaceVector from which the cross product
is taken in conjunction with this SpaceVector.getCrossProduct(SpaceVector sv)public java.lang.String toString()
String representation of this SpaceVector
object. The value represented by this SpaceVector
is converted to a String in the standard component vector format of
< x, y, z > .String representation of this object.public int hashCode()
hashCode() generated
by the String returned from
toString() of this SpaceVector.toString()public boolean equals(java.lang.Object o)
Object parameter is equal to this
SpaceVector or not.public boolean equals(SpaceVector sv)
SpaceVector argument.
public final boolean equals(float X,
float Y,
float Z)
public java.lang.Object clone()
SpaceVector.
public static final boolean equal(float f1,
float f2)
floats are close enough
together to be considered equal.
public static final boolean equal(double d1,
double d2)
doubles are close enough
together to be considered equal.
public final void paintLine(float initialX,
float initialY,
float initialZ,
int centX,
int centY,
java.awt.Color color,
java.awt.Graphics g)
public final void paintArrow(float initialX,
float initialY,
float initialZ,
int centX,
int centY,
int screenDistance,
float arrowSize,
java.awt.Color color,
java.awt.Graphics g)
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||