healpix.tools
Class SpatialVector

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

public class SpatialVector
extends Vec3

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.


Field Summary
 
Fields inherited from class healpix.essentials.Vec3
x, y, z
 
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
SpatialVector(Vec3 v)
           
 
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()
           
 SpatialVector mul(double n)
          multiply with a number
 void normalized()
          Normalized this vector
 double ra()
          Get the ra angle in degrees
 void set_z_phi(double zin, double phi)
          convenience function - added as it is in C++ version
 void set(double ra, double dec)
          Sets the ra and dec angles in degrees
 SpatialVector sub(SpatialVector v)
          vector subtraction
 String toString()
           
 double x()
           
 double y()
           
 double z()
           
 
Methods inherited from class healpix.essentials.Vec3
add, angle, cross, dot, flip, length, lengthSquared, normalize, scale, sub, toArray, toArray
 
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(Vec3 v)

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

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 Vec3

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 Vec3

hashCode

public int hashCode()
Overrides:
hashCode in class Vec3

mul

public SpatialVector mul(double n)
multiply with a number

Overrides:
mul in class Vec3
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

set_z_phi

public void set_z_phi(double zin,
                      double phi)
convenience function - added as it is in C++ version

Parameters:
zin -
phi -

"Built from revision exported"