Package ucar.nc2.dt.ugrid.geom
Class Vector3D
java.lang.Object
ucar.nc2.dt.ugrid.geom.Vector3D
Holds the u, v and w components of a vector as well as it's origin (
Point3D).
The class also provides methods to perform mathematical operations on this and other vectors (addition, subtraction, multiplication, division, cross multiplication, and dot multiplication)
-
Constructor Summary
ConstructorsConstructorDescriptionVector3D()Creates a new instance of Vector3D with an origin of (0, 0, 0) and no magnitude (u=0, v=0, w=0)Vector3D(double u, double v, double w) Creates a new instance of Vector3D with an origin of (0, 0, 0) and the specified u, v, and w magnitudes.Creates a new instance of Vector3D with the specified origin and u, v, and w magnitudes. -
Method Summary
Modifier and TypeMethodDescriptionstatic Vector3DAdds the numerical value of each component of the first vector with the values in the second vector.Determines the cross product of thisVector3Dwith the one givenstatic Vector3DDetermines the cross product of the two given vectorsstatic Vector3DDivides the numerical value of each component of the vector by a given scalar.doubleDetermines the dot product of thisVector3Dwith the one givenstatic doubleDetermines the dot product of the two given vectorsGets thePoint3Dindicated by applying the vector(u, v, w)components to theorigindoubleGets the magnitude of thisVector3D.Gets the origin of thisVector3DdoublegetU()Returns the u component of the vector.doublegetV()Returns the v component of the vector.doublegetW()Returns the w component of the vector.static Vector3DMultiplies the numerical value of each component of the vector by a given scalar.voidSets the origin of thisVector3DvoidsetU(double u) Sets the u component of the vector.voidsetV(double v) Sets the v component of the vector.voidsetW(double w) Sets the w component of the vector.static Vector3DSubtracts the numerical value of each component of the second vector from the values in the first vector.Builds a descriptive string presenting the u, v, and w components of this vector
-
Constructor Details
-
Vector3D
public Vector3D()Creates a new instance of Vector3D with an origin of (0, 0, 0) and no magnitude (u=0, v=0, w=0) -
Vector3D
public Vector3D(double u, double v, double w) Creates a new instance of Vector3D with an origin of (0, 0, 0) and the specified u, v, and w magnitudes.- Parameters:
u- Thedoubleu-component of the vector.v- Thedoublev-component of the vector.w- Thedoublew-component of the vector.
-
Vector3D
Creates a new instance of Vector3D with the specified origin and u, v, and w magnitudes.- Parameters:
origin- thePoint3Dorigin of the vector.u- Thedoubleu-component of the vector.v- Thedoublev-component of the vector.w- Thedoublew-component of the vector.
-
-
Method Details
-
getOrigin
Gets the origin of thisVector3D- Returns:
- the origin
-
setOrigin
Sets the origin of thisVector3D- Parameters:
origin- the new origin
-
getU
public double getU()Returns the u component of the vector.- Returns:
doubleThe u component.
-
setU
public void setU(double u) Sets the u component of the vector.- Parameters:
u-doubleThe u component.
-
getV
public double getV()Returns the v component of the vector.- Returns:
doubleThe v component.
-
setV
public void setV(double v) Sets the v component of the vector.- Parameters:
v-doubleThe v component.
-
getW
public double getW()Returns the w component of the vector.- Returns:
doubleThe w component.
-
setW
public void setW(double w) Sets the w component of the vector.- Parameters:
w-doubleThe w component.
-
toString2
Builds a descriptive string presenting the u, v, and w components of this vector- Returns:
- a descriptive
String
-
getMagnitude
public double getMagnitude()Gets the magnitude of thisVector3D.NOTE: Units are NOT considered, the units of magnitude are the same as those of the vector components.
- Returns:
- the vector magnitude
-
getEndPoint
Gets thePoint3Dindicated by applying the vector(u, v, w)components to theoriginNOTE: Units are NOT considered. The units of the
originand(u, v, w)components are assumed to be the same.
Therefore conversions (i.e. from DD to Meters) should happen BEFORE calling this method.- Returns:
- the end point.
-
add
Adds the numerical value of each component of the first vector with the values in the second vector.- Parameters:
v1- the firstVector3Dv2- the secondVector3D- Returns:
- a
Vector3Drepresenting the addition of the two vectors
-
sub
Subtracts the numerical value of each component of the second vector from the values in the first vector.- Parameters:
v1- the firstVector3Dv2- the secondVector3D- Returns:
- a
Vector3Drepresenting the subtraction of the two vectors
-
mult
Multiplies the numerical value of each component of the vector by a given scalar.- Parameters:
v- theVector3Dd- the value to multiply the vector by- Returns:
- a
Vector3Drepresenting the rescaled vector
-
div
Divides the numerical value of each component of the vector by a given scalar.- Parameters:
v- theVector3Dd- the value to divide the vector by- Returns:
- a
Vector3Drepresenting the rescaled vector
-
cross
Determines the cross product of the two given vectors- Parameters:
v1- the firstVector3Dv2- the secondVector3D- Returns:
- a
Vector3Dwhich is perpendicular to the plane containing the given vector's. i.e. Cross product.
-
cross
Determines the cross product of thisVector3Dwith the one given- Parameters:
other- anotherVector3D- Returns:
- a
Vector3Drepresenting the cross product of this vector and the one given
-
dot
Determines the dot product of the two given vectors- Parameters:
v1- the firstVector3Dv2- the secondVector3D- Returns:
- a
Vector3Dwhich represents the dot product of the given vectors.
-
dot
Determines the dot product of thisVector3Dwith the one given- Parameters:
other- anotherVector3D- Returns:
- a
Vector3Drepresenting the dot product of this vector and the one given
-