NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links


healpix.tools
Class SpatialVector

java.lang.Object
  extended by healpix.tools.SpatialVector

public class SpatialVector
extends Object

The SpatialVector contains standard 3D vector with the addition that each coordinate (x,y,z) is also kept in ra,dec since we expect the vector to live on the surface of the unit sphere, i.e.

  2   2   2
  x + y + z  = 1
 
This is not enforced, so you can specify a vector that has not unit length. If you request the ra/dec of such a vector, it will be automatically normalized to length 1 and you get the ra/dec of that vector (the intersection of the vector's direction with the unit sphere. This code comes originally from the HTM library of Peter Kunst during his time at JHU.


Constructor Summary
SpatialVector()
          Default constructor constructs (1,0,0), ra=0, dec=0.
SpatialVector(double ra, double dec)
          Construct from ra/dec in degrees
SpatialVector(double x1, double y1, double z1)
          Constructor from three coordinates
SpatialVector(SpatialVector copy)
          Copy constructor - be aware this only copies x,y,z
 
Method Summary
 SpatialVector add(SpatialVector v)
          vector addition
 double angle(SpatialVector v1)
          Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].
 SpatialVector cross(SpatialVector v)
          vector cross product
 double dec()
          Get the dec angle in degrees
 double dot(SpatialVector v1)
          Computes the dot product of the this vector and vector v1.
 boolean equal(SpatialVector v)
          Compare vectors if coordinates are equals
 boolean equals(Object obj)
           
 double[] get()
          Get the coordinates in a 3 elements 1D array
 int hashCode()
           
 double length()
          Returns the length of this vector.
 double lengthSquared()
          Returns the squared length of this vector.
 SpatialVector mul(double n)
          multiply with a number
 void normalized()
          Normalized this vector
 double ra()
          Get the ra angle in degrees
 void set(double ra, double dec)
          Sets the ra and dec angles in degrees
 SpatialVector sub(SpatialVector v)
          vector subtraction
 double toDe()
           
 double toRa()
           
 String toString()
           
 double x()
           
 double y()
           
 double z()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpatialVector

public SpatialVector()
Default constructor constructs (1,0,0), ra=0, dec=0.


SpatialVector

public SpatialVector(double x1,
                     double y1,
                     double z1)
Constructor from three coordinates

Parameters:
x1 -
y1 -
z1 -

SpatialVector

public SpatialVector(double ra,
                     double dec)
Construct from ra/dec in degrees

Parameters:
ra - RA in degrees
dec - DEC in degrees

SpatialVector

public SpatialVector(SpatialVector copy)
Copy constructor - be aware this only copies x,y,z

Parameters:
copy - the vector to copy
Method Detail

length

public final double length()
Returns the length of this vector.

Returns:
the length of this vector

lengthSquared

public final double lengthSquared()
Returns the squared length of this vector.

Returns:
the squared length of this vector

normalized

public void normalized()
Normalized this vector


set

public void set(double ra,
                double dec)
Sets the ra and dec angles in degrees

Parameters:
ra - right ascension angle in degrees
dec - declination angle in degrees

angle

public final double angle(SpatialVector v1)
Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].

Parameters:
v1 - the other vector
Returns:
the angle in radians in the range [0,PI]

get

public double[] get()
Get the coordinates in a 3 elements 1D array

Returns:
coordinates [x,y,z]

x

public double x()
Returns:
x

y

public double y()
Returns:
y

z

public double z()
Returns:
z

toString

public String toString()
Overrides:
toString in class Object

cross

public SpatialVector cross(SpatialVector v)
vector cross product

Parameters:
v - the vector to cross
Returns:
the vector cross product

equal

public boolean equal(SpatialVector v)
Compare vectors if coordinates are equals

Parameters:
v - the vector to be compared with
Returns:
true if both coordinates of vectors are equal

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

mul

public SpatialVector mul(double n)
multiply with a number

Parameters:
n - the scale number to be multiply to the coordinates x,y,z
Returns:
the vector with coordinates multiplied by n

dot

public final double dot(SpatialVector v1)
Computes the dot product of the this vector and vector v1.

Parameters:
v1 - the other vector
Returns:
dot product

add

public SpatialVector add(SpatialVector v)
vector addition

Parameters:
v - the vector to be added
Returns:
vector result by addition

sub

public SpatialVector sub(SpatialVector v)
vector subtraction

Parameters:
v - the vector to be substracted
Returns:
vector result by substraction

dec

public double dec()
Get the dec angle in degrees

Returns:
declination angle

ra

public double ra()
Get the ra angle in degrees

Returns:
right ascension

toRa

public double toRa()
Returns:
Right Ascencion of this vector in radians

toDe

public double toDe()
Returns:
Declination of this vector in radians

"Built from revision exported"

Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650