Modifier and Type | Field and Description |
---|---|
double |
x
X-coordinate - immutable but directly accessible.
|
double |
y
Y-coordinate - immutable but directly accessible.
|
double |
z
Z-coordinate - immutable but directly accessible.
|
Constructor and Description |
---|
StdDraw3D.Vector3D()
Initializes to zero vector.
|
StdDraw3D.Vector3D(double[] c)
Initializes to the given coordinates.
|
StdDraw3D.Vector3D(double x,
double y,
double z)
Initializes to the given coordinates.
|
Modifier and Type | Method and Description |
---|---|
double |
angle(StdDraw3D.Vector3D that)
Returns the smallest angle between this and that vector, in DEGREES.
|
StdDraw3D.Vector3D |
cross(StdDraw3D.Vector3D that)
Returns the cross product of this vector with that vector.
|
StdDraw3D.Vector3D |
direction()
Returns the unit vector in the direction of this vector.
|
double |
distanceTo(StdDraw3D.Vector3D that)
Returns the Euclidian distance between this and that.
|
double |
dot(StdDraw3D.Vector3D that)
Returns the dot product of this and that.
|
void |
draw()
Draws this vector as a point from the origin to StdDraw3D.
|
double |
mag()
Returns the magnitude of this vector.
|
StdDraw3D.Vector3D |
minus(double x,
double y,
double z) |
StdDraw3D.Vector3D |
minus(StdDraw3D.Vector3D that)
Returns the difference of this and that vector.
|
StdDraw3D.Vector3D |
plus(double x,
double y,
double z) |
StdDraw3D.Vector3D |
plus(StdDraw3D.Vector3D that)
Returns the sum of this and that vector.
|
StdDraw3D.Vector3D |
proj(StdDraw3D.Vector3D line)
Returns the projection of this onto the given line.
|
StdDraw3D.Vector3D |
reflect(StdDraw3D.Vector3D line)
Reflects this vector across the direction given by line.
|
StdDraw3D.Vector3D |
times(double k)
Returns the product of this vector and the scalar k.
|
StdDraw3D.Vector3D |
times(double a,
double b,
double c)
Returns the result (this.x * a, this.y * b, this.z * c).
|
String |
toString()
Returns a string representation of this vector.
|
public final double x
public final double y
public final double z
public StdDraw3D.Vector3D()
public StdDraw3D.Vector3D(double x, double y, double z)
x
- X-coordinatey
- Y-coordinatez
- Z-coordinatepublic StdDraw3D.Vector3D(double[] c)
c
- Array length 3 of coordinates (x, y, z,).public double dot(StdDraw3D.Vector3D that)
that
- Vector to dot withpublic double mag()
public double angle(StdDraw3D.Vector3D that)
public double distanceTo(StdDraw3D.Vector3D that)
that
- Vector to compute distance betweenpublic StdDraw3D.Vector3D plus(StdDraw3D.Vector3D that)
that
- Vector to compute sum withpublic StdDraw3D.Vector3D plus(double x, double y, double z)
public StdDraw3D.Vector3D minus(StdDraw3D.Vector3D that)
that
- Vector to compute difference withpublic StdDraw3D.Vector3D minus(double x, double y, double z)
public StdDraw3D.Vector3D times(double k)
k
- Scalar to multiply bypublic StdDraw3D.Vector3D times(double a, double b, double c)
a
- Scalar to multiply x byb
- Scalar to multiply y byc
- Scalar to multiply z bypublic StdDraw3D.Vector3D direction()
public StdDraw3D.Vector3D proj(StdDraw3D.Vector3D line)
line
- Direction to project this vector ontopublic StdDraw3D.Vector3D cross(StdDraw3D.Vector3D that)
public StdDraw3D.Vector3D reflect(StdDraw3D.Vector3D line)
line
- Direction to reflect this vector overpublic String toString()
public void draw()