HTM Index 1.0




jhu.htmIndex
Class SpatialVector

java.lang.Object
  |
  +--jhu.htmIndex.SpatialVector

public class SpatialVector
extends java.lang.Object

The SpatialVector is a standard 3D vector class 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.


Constructor Summary
SpatialVector()
          Default cunstructor constructs (1,0,0), ra=0, dec=0.
SpatialVector(double ra, double dec)
          Construct from ra/dec
SpatialVector(double x, double y, double z)
          Constructor from three coordinates
SpatialVector(SpatialVector copy)
          Copy constructor
 
Method Summary
 SpatialVector add(SpatialVector v)
          vector addition
 SpatialVector cross(SpatialVector v)
          vector cross product
 double dec()
          return dec
 boolean equal(SpatialVector v)
          comparison
 double[] get()
          Get x,y,z
 double length()
          return length of vector
 SpatialVector mul(double n)
          multiply with a number
 double mul(SpatialVector v)
          dot product
 void normalize()
          Normalize vector length to 1
 double ra()
          return ra
 void read(java.io.Reader in)
          read from a stream as X Y Z
 void readRaDec(java.io.Reader in)
          read from a stream as RA DEC
 void set(double ra, double dec)
          Set member function: set values using ra/dec
 void set(double x, double y, double z)
          Set member function: set values
 SpatialVector sub(SpatialVector v)
          vector subtraction
 java.lang.String toString()
          convert to string : print x y z as "x y z"
protected  void updateRaDec()
          Update ra_ and dec_ from x_ y_ z_ variables
protected  void updateXYZ()
          Update x_ y_ z_ from ra_ and dec_ variables
 double x()
          return x (only as rvalue)
 double y()
          return y
 double z()
          return z
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpatialVector

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

SpatialVector

public SpatialVector(double x,
                     double y,
                     double z)
Constructor from three coordinates

SpatialVector

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

SpatialVector

public SpatialVector(SpatialVector copy)
Copy constructor
Method Detail

set

public void set(double x,
                double y,
                double z)
Set member function: set values

set

public void set(double ra,
                double dec)
Set member function: set values using ra/dec

get

public double[] get()
Get x,y,z

length

public double length()
return length of vector

x

public double x()
return x (only as rvalue)

y

public double y()
return y

z

public double z()
return z

normalize

public void normalize()
Normalize vector length to 1

toString

public java.lang.String toString()
convert to string : print x y z as "x y z"
Overrides:
toString in class java.lang.Object

cross

public SpatialVector cross(SpatialVector v)
vector cross product

equal

public boolean equal(SpatialVector v)
comparison

mul

public SpatialVector mul(double n)
multiply with a number

mul

public double mul(SpatialVector v)
dot product

add

public SpatialVector add(SpatialVector v)
vector addition

sub

public SpatialVector sub(SpatialVector v)
vector subtraction

dec

public double dec()
return dec

ra

public double ra()
return ra

updateXYZ

protected void updateXYZ()
Update x_ y_ z_ from ra_ and dec_ variables

updateRaDec

protected void updateRaDec()
Update ra_ and dec_ from x_ y_ z_ variables

read

public void read(java.io.Reader in)
          throws java.io.IOException
read from a stream as X Y Z

readRaDec

public void readRaDec(java.io.Reader in)
               throws java.io.IOException
read from a stream as RA DEC

HTM Index 1.0





©Copyright The Johns Hopkins University 1999, All Rights Reserved.
See the HTM Homepage for details.
Last Build: Oct 26, 1999 Peter Z. Kunszt