- java.lang.Object
-
- spice.basic.Vector3
-
- Direct Known Subclasses:
EllipsoidPointNearPoint
,LimbPoint
,PositionVector
,SubObserverRecord
,SubSolarRecord
,SurfacePoint
,TerminatorPoint
,VelocityVector
public class Vector3 extends java.lang.Object
Class Vector3 represents and provides methods implementing mathematical operations on three-dimensional vectors.Supported operations include:
addition
add(spice.basic.Vector3)
cross productcross(spice.basic.Vector3)
dot productdot(spice.basic.Vector3)
distance between vectorsdist(spice.basic.Vector3)
unitize vectorhat()
test for equality to zeroisZero()
two-vector linear combinationlcom(double a, Vector3 v1, double b, Vector3 v2)
three-vector linear combinationlcom(double a, Vector3 v1, double b, Vector3 v2, double c, Vector3 v3)
vector negationnegate()
vector normnorm()
vector perpendicular componentperp(spice.basic.Vector3)
vector projection onto vectorproj(spice.basic.Vector3)
rotate vector about coordinate axisrotate(int axisIndex, double angle)
rotate vector about vectorrotate(Vector3 axisVector, double angle)
scalar multiplicationscale(double)
angular separationsep(spice.basic.Vector3)
subtractionsub(spice.basic.Vector3)
unitized cross productucross(spice.basic.Vector3)
For methods involving derivatives of functions of 3-dimensional vectors, such as derivatives of dot products, see the class
Vector6
.Version 1.0.0 17-NOV-2009 (NJB)
-
-
Field Summary
Fields Modifier and Type Field Description (package private) double[]
v
-
Constructor Summary
Constructors Constructor Description Vector3()
Construct a zero-filled Vector3.Vector3(double[] vin)
Construct a Vector3 from an array of 3 doubles.Vector3(double v0, double v1, double v2)
Construct a Vector3 from three double scalars.Vector3(Vector3 vin)
Copy constructor: create a new Vector3 from another.
-
Method Summary
Modifier and Type Method Description Vector3
add(Vector3 v2)
Add two 3 dimensional vectors.void
assign(double[] values)
Assign the contents of an array of three doubles to a Vector3.Vector3
cross(Vector3 v2)
Compute the cross product of two 3-dimensional vectors.double
dist(Vector3 v1)
Return the distance between two three-dimensional vectors.double
dot(Vector3 v2)
Compute the dot product of two double precision, 3-dimensional vectors.double
getElt(int i)
Return the element of this instance at index [i].Vector3
hat()
Find the unit vector along a double precision 3-dimensional vector.boolean
isZero()
Indicate whether a 3-vector is the zero vector.static Vector3
lcom(double a, Vector3 v1, double b, Vector3 v2)
Compute a vector linear combination of two double precision, 3-dimensional vectors.static Vector3
lcom(double a, Vector3 v1, double b, Vector3 v2, double c, Vector3 v3)
Compute a vector linear combination of three double precision, 3-dimensional vectors.Vector3
negate()
Negate a double precision 3-dimensional vector.double
norm()
Compute the magnitude of a double precision, 3-dimensional vector.Vector3
perp(Vector3 v2)
Find the component of this vector orthogonal to a given vector.Vector3
proj(Vector3 v2)
Find the orthogonal projection of this vector onto a given vector.Vector3
rotate(int axisIndex, double angle)
Transform this vector into a basis that is rotated in the counterclockwise sense about a given coordinate axis by a given angle.Units are radians.Vector3
rotate(Vector3 axisVector, double angle)
Rotate this vector in the counterclockwise sense about a given vector by a given angle.Units are radians.Vector3
scale(double s)
Multiply a Vector3 by a scalar.double
sep(Vector3 v2)
Find the separation angle in radians between two double precision, 3-dimensional vectors.This angle is defined as zero if either vector is zero.Vector3
sub(Vector3 v2)
Compute the difference between two 3-dimensional, double precision vectors.double[]
toArray()
Return the contents of a Vector3 in an array of 3 doubles.java.lang.String
toString()
Return a string representation of the contents of a Vector3.This overrides Object's toString method.Vector3
ucross(Vector3 v2)
Return the unitized cross product of this vector and a given vector.
-
-
-
Constructor Detail
-
Vector3
public Vector3()
Construct a zero-filled Vector3.
-
Vector3
public Vector3(Vector3 vin)
Copy constructor: create a new Vector3 from another.- Parameters:
vin
-
-
Vector3
public Vector3(double[] vin)
Construct a Vector3 from an array of 3 doubles.- Parameters:
vin
-
-
Vector3
public Vector3(double v0, double v1, double v2)
Construct a Vector3 from three double scalars.- Parameters:
v0
-v2
-v1
-
-
-
Method Detail
-
assign
public void assign(double[] values) throws SpiceException
Assign the contents of an array of three doubles to a Vector3.- Parameters:
values
- double[]- Throws:
SpiceException
- exeption
-
add
public Vector3 add(Vector3 v2)
Add two 3 dimensional vectors.- Parameters:
v2
- Vector3- Returns:
- Vector3
-
cross
public Vector3 cross(Vector3 v2)
Compute the cross product of two 3-dimensional vectors.- Parameters:
v2
- Vector3- Returns:
- Vector3
-
dist
public double dist(Vector3 v1)
Return the distance between two three-dimensional vectors.- Parameters:
v1
- Vector3- Returns:
- double
-
dot
public double dot(Vector3 v2)
Compute the dot product of two double precision, 3-dimensional vectors.- Parameters:
v2
- Vector3- Returns:
- double
-
getElt
public double getElt(int i) throws SpiceException
Return the element of this instance at index [i].- Parameters:
i
- int- Returns:
- double
- Throws:
SpiceException
- exeption
-
hat
public Vector3 hat()
Find the unit vector along a double precision 3-dimensional vector.- Returns:
- Vector3
-
isZero
public boolean isZero()
Indicate whether a 3-vector is the zero vector.- Returns:
- boolean
-
lcom
public static Vector3 lcom(double a, Vector3 v1, double b, Vector3 v2)
Compute a vector linear combination of two double precision, 3-dimensional vectors.- Parameters:
a
- dobulev2
- Vector3v1
- Vector3b
- double- Returns:
- Vector3
-
lcom
public static Vector3 lcom(double a, Vector3 v1, double b, Vector3 v2, double c, Vector3 v3)
Compute a vector linear combination of three double precision, 3-dimensional vectors.- Parameters:
a
- doublev3
- Vector3v1
- Vector3c
- doubleb
- doublev2
- Vector3- Returns:
- Vector3
-
negate
public Vector3 negate()
Negate a double precision 3-dimensional vector.- Returns:
- Vector3
-
norm
public double norm()
Compute the magnitude of a double precision, 3-dimensional vector.- Returns:
- double
-
perp
public Vector3 perp(Vector3 v2) throws SpiceException
Find the component of this vector orthogonal to a given vector.- Parameters:
v2
- Vector3- Returns:
- Vector3
- Throws:
SpiceException
- exeption
-
proj
public Vector3 proj(Vector3 v2) throws SpiceException
Find the orthogonal projection of this vector onto a given vector.- Parameters:
v2
- Vector3- Returns:
- Vector3
- Throws:
SpiceException
- exeption
-
rotate
public Vector3 rotate(int axisIndex, double angle) throws SpiceException
Transform this vector into a basis that is rotated in the counterclockwise sense about a given coordinate axis by a given angle.Units are radians.Equivalently, this method rotates this vector by the negative of the input angle about the indicated axis.
The coordinate axis is identified by an integer:
1 == X axis 2 == Y axis 3 == Z axis
- Parameters:
axisIndex
- intangle
- double- Returns:
- Vector3
- Throws:
SpiceException
- exeption
-
rotate
public Vector3 rotate(Vector3 axisVector, double angle) throws SpiceException
Rotate this vector in the counterclockwise sense about a given vector by a given angle.Units are radians.- Parameters:
axisVector
- Vector3angle
- double- Returns:
- Vector3
- Throws:
SpiceException
- exeption
-
scale
public Vector3 scale(double s)
Multiply a Vector3 by a scalar.- Parameters:
s
- double- Returns:
- Vector3
-
sub
public Vector3 sub(Vector3 v2)
Compute the difference between two 3-dimensional, double precision vectors.- Parameters:
v2
- Vector3- Returns:
- Vector3
-
sep
public double sep(Vector3 v2)
Find the separation angle in radians between two double precision, 3-dimensional vectors.This angle is defined as zero if either vector is zero.- Parameters:
v2
- Vector3- Returns:
- double
-
toArray
public double[] toArray()
Return the contents of a Vector3 in an array of 3 doubles.- Returns:
- double[]
-
toString
public java.lang.String toString()
Return a string representation of the contents of a Vector3.This overrides Object's toString method.- Overrides:
toString
in classjava.lang.Object
- Returns:
- String
-
ucross
public Vector3 ucross(Vector3 v2) throws SpiceException
Return the unitized cross product of this vector and a given vector.Return the zero vector if the cross product is zero.
- Parameters:
v2
- Vector3- Returns:
- Vector3
- Throws:
SpiceException
- exeption
-
-