Package uk.ac.starlink.dpac.epoch
Class GVector3d
java.lang.Object
uk.ac.starlink.dpac.epoch.GVector3d
Class representing a three-dimensional vector in Eucledian space. The space
is spanned by a right-handed, orthonormal triad designated [X, Y, Z] in the
following.
The class suppors all the usual methods to perform conventional vector arithmetics such as vector and dot product.
- Version:
- $Id: GVector3d.java 359256 2014-04-07 17:09:18Z hsiddiqu $
- Author:
- aolias
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs and initializes aGVector3dto(0, 0, 0)GVector3d(double s) Constructs and initializes aGVector3dto the tuple(s, s, s).GVector3d(double[] v) Constructs and initializes aGVector3dfrom the first 3 elements of a given double array.GVector3d(double x, double y, double z) Constructs and initializes aGVector3dfrom a specified(x, y, z)tuple.The copy constructor - constructs a newGVector3dfrom a given one by copying all elements. -
Method Summary
Modifier and TypeMethodDescriptionadd(double r) Adds a scalarrto all coordinates of the vector, i.e.,this = this + (r, r, r).Adds another vectorvto this one, i.e.static GVector3dAdds two vectors and return the result a new one.Sets this vector to the outer product of itself and a second vectorv, i.e.static GVector3dCalculates the outer product of two given vectorsvandwand returns the result as a newGVector3d.doubleCalculates the dot product of this and another given vector.doublegetX()doublegetY()doublegetZ()static GVector3d[]localTriad(double alpha, double delta) Computes the normal triad [p q r] at spherical coordinates(alpha, delta)scale(double s) Scales the vector by a scalars, i.e.static GVector3dConstructs new vector from scaling a given one.Scales a given vector with a scalar and add the result to this one, i.e.static GVector3dConstructs new vector as sum of a given vectorv1and a scaled vectors*v2.set(double x, double y, double z) Sets the elements of this vector to given 3-tuple.doublex()Identical togetX()doubley()Identical togetY()doublez()Identical togetZ()
-
Constructor Details
-
GVector3d
public GVector3d()Constructs and initializes aGVector3dto(0, 0, 0) -
GVector3d
public GVector3d(double s) Constructs and initializes aGVector3dto the tuple(s, s, s).- Parameters:
s- double value to be assigned to all components
-
GVector3d
Constructs and initializes aGVector3dfrom the first 3 elements of a given double array.- Parameters:
v- array of length >=3 to initialize this vector from- Throws:
IllegalArgumentException- if input array has less than three elements
-
GVector3d
public GVector3d(double x, double y, double z) Constructs and initializes aGVector3dfrom a specified(x, y, z)tuple.- Parameters:
x-xcoordinatey-ycoordinatez-zcoordinate
-
GVector3d
The copy constructor - constructs a newGVector3dfrom a given one by copying all elements.- Parameters:
v- Vector to set this object to
-
-
Method Details
-
set
Sets the elements of this vector to given 3-tuple.- Parameters:
x- new value of theXcoordinatey- new value of theYcoordinatez- new value of theZcoordinate- Returns:
- GVector3d
-
getX
public double getX()- Returns:
Xcoordinate value of this vector
-
getY
public double getY()- Returns:
Ycoordinate value of this vector
-
getZ
public double getZ()- Returns:
Zcoordinate value of this vector
-
x
public double x()Identical togetX()- Returns:
- double
-
y
public double y()Identical togetY()- Returns:
- double
-
z
public double z()Identical togetZ()- Returns:
- double
-
localTriad
Computes the normal triad [p q r] at spherical coordinates(alpha, delta)- Parameters:
alpha- longitude [rad] (0<=alpha<2 Pi)delta- latitude [rad] (-Pi/2<=delta<=Pi/2)- Returns:
- computed normal trid as three element array 0: unit vector in the
direction of increasing
alpha1: unit vector in the direction of increasingdelta2: unit vector towards the point(alpha, delta)
-
add
Adds a scalarrto all coordinates of the vector, i.e.,this = this + (r, r, r).- Parameters:
r- scalar to add to all coordinates- Returns:
- vector modified in place
-
add
Adds another vectorvto this one, i.e.this = this + v.- Parameters:
v- vector to add- Returns:
- vector modified in place
-
add
Adds two vectors and return the result a new one.- Parameters:
v- first operandw- second operand- Returns:
- sum of
vandw
-
cross
Sets this vector to the outer product of itself and a second vectorv, i.e.this = this x v- Parameters:
vec- vector with which to build the outer product- Returns:
- vector modified in place
-
cross
Calculates the outer product of two given vectorsvandwand returns the result as a newGVector3d.- Parameters:
v- left operandw- right operand- Returns:
- outer product of
vandw
-
dot
Calculates the dot product of this and another given vector.- Parameters:
v- vector to build the dot product with- Returns:
- dot product of this vector and
v
-
scale
Scales the vector by a scalars, i.e.this = s*this- Parameters:
s- scalar to scale the vector with- Returns:
- vector modified in place
-
scale
Constructs new vector from scaling a given one.- Parameters:
s- scalar scaling factorv- vector to scale- Returns:
- product of
sandvas a newGVector3d
-
scaleAdd
Scales a given vector with a scalar and add the result to this one, i.e.this = this + s*v.- Parameters:
s- scalar scaling factorv- vector to scale- Returns:
- vector modified in place
-
scaleAdd
Constructs new vector as sum of a given vectorv1and a scaled vectors*v2.- Parameters:
v1- first vectors- scalar scaling factorv2- second vector- Returns:
- new vector set to
v1+s*v2
-