public class Vector
extends java.lang.Object
Constructor and Description |
---|
Vector(double x,
double y,
double z)
Create a new
Vector , from its x, y, and z values. |
Modifier and Type | Method and Description |
---|---|
Vector |
add(Vector other)
Add a second
Vector to this . |
double |
calcAngle(Vector other)
Calculate the angle between
this and a second Vector . |
Vector |
calcCrossProduct(Vector other)
Calculate the cross product of
this with another Vector . |
double |
calcDotProduct(Vector other)
Calculate the dot product of
this with another Vector . |
double |
calcLength()
Calculate the length of
this . |
boolean |
equals(Vector other)
Build a
true if this is equivalent to other ; otherwise false. |
double |
getX()
Accessor for the x coordinate.
|
double |
getY()
Accessor for the y coordinate.
|
double |
getZ()
Accessor for the z coordinate.
|
Vector |
makeNormalizedVector()
Create a new
Vector with the same proportions as this , but with a length of exactly 1.0 . |
Vector |
multiply(double scalar)
Multiply
this by a scalar value. |
void |
setX(double newX)
Mutator for the x coordinate.
|
void |
setY(double newY)
Mutator for the y coordinate.
|
void |
setZ(double newZ)
Mutator for the z coordinate.
|
Vector |
subtract(Vector other)
Subtract a second
Vector from this . |
java.lang.String |
toString()
Build a
String representing this Vector , as [x, y, z] . |
public Vector(double x, double y, double z)
Vector
, from its x, y, and z values.public Vector add(Vector other)
Vector
to this
.other
- the other Vector
to addVector
public Vector subtract(Vector other)
Vector
from this
.other
- the other Vector
to subtractVector
public Vector multiply(double scalar)
this
by a scalar value.scalar
- the value by which to multiplyVector
public Vector calcCrossProduct(Vector other)
this
with another Vector
.other
- the other Vector
Vector
public double calcDotProduct(Vector other)
this
with another Vector
.other
- the other Vector
public double calcLength()
this
.public Vector makeNormalizedVector()
Vector
with the same proportions as this
, but with a length of exactly 1.0
.Vector
public double calcAngle(Vector other)
this
and a second Vector
.other
- the other Vector
public java.lang.String toString()
String
representing this Vector
, as [x, y, z]
.toString
in class java.lang.Object
[x, y, z]
public boolean equals(Vector other)
true
if this
is equivalent to other
; otherwise false.other
- the other Vector
public double getX()
public double getY()
public double getZ()
public void setX(double newX)
newX
- the new x coordinatepublic void setY(double newY)
newY
- the new y coordinatepublic void setZ(double newZ)
newZ
- the new z coordinate