|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcds.astro.Coo
public class Coo
Class that manipulates the coordinates defining a point on the celestial sphere. The class includes conversions between polar angles (lon,lat) expressed in degrees, and Cartesian 3-vectors. The typical way of converting between polar and cartesian is:
Coo aCoo = new Coo ; double u[] = new double[3] ; while (true) { aCoo.set(stdin.readLine()) ; System.out.println("Coordonnees : " + aCoo) ; u[0] = aCoo.x; u[1] = aCoo.y; u[2] = aCoo.z; System.out.println("Cos. directeurs: " + Coo.toString(u)) ; }This class also deals with 3x3 matrices.
Field Summary | |
---|---|
static int |
decimals
Number of decimals edited in the default toString method. |
static Editing |
ed
The edition of Coordinates |
static double[][] |
Umatrix3
The unit 3-D unit matrix . |
double |
x
Components of unit vector (direction cosines) |
double |
y
Components of unit vector (direction cosines) |
double |
z
Components of unit vector (direction cosines) |
Constructor Summary | |
---|---|
Coo()
The basic contructor: undefined position |
|
Coo(double lon,
double lat)
Define a coordinate from its angles |
|
Coo(double x,
double y,
double z)
Define a coordinate from its direction cosines. |
|
Coo(java.lang.String text)
Define a coordinate from a string |
Method Summary | |
---|---|
double |
add(double[] du)
Addition of a vector (addition, then normalisation) |
static double |
add(double[] u,
double[] du)
Addition of a vector (addition, then normalisation) |
java.lang.Object |
clone()
Clone the Coo object |
void |
copyAngles(double[] o)
Get the spherical angles (lon, lat) as a 2-vector |
void |
copyUvector(double[] u)
Get the unit vector (x, y, z) as a 3-vector |
double |
distance(Coo pos)
Distance between 2 points on the sphere. |
static double |
distance(double lon1,
double lat1,
double lon2,
double lat2)
Distance between 2 points on the sphere. |
void |
dump(java.lang.String title)
Dump the contents of a Coordinate |
java.lang.StringBuffer |
edit(java.lang.StringBuffer b,
int nd)
Default Edition of the Coordinates, as 2 numbers expressing the angles in degrees. |
java.lang.StringBuffer |
editCoo(java.lang.StringBuffer b,
int nd)
Edition of the Coordinates with specified number of decimals. |
boolean |
equals(java.lang.Object o)
Test equality of Coo. |
static double[][] |
eulerMatrix(double z,
double theta,
double zeta)
Generate the rotation matrix from the Euler angles |
double |
getLat()
Get the Latitude (Dec) in degrees. |
double |
getLon()
Get the Longitude (RA) in degrees. |
double[][] |
localMatrix()
Compute the rotation matrix associated to current position. |
void |
localMatrix(double[][] R)
Compute the rotation matrix associated to current position. |
static double[][] |
localMatrix(double lon,
double lat)
Compute the rotation matrix that transforms a direction into the local frame. |
double[][] |
moveMatrix(Coo coo2)
Compute the rotation matrix to move between 2 directions. |
double |
normalize()
Normalisation of coordinates (set its norm to 1) |
static double |
normalize(double[] u)
Normalisation of a vector (set its norm to 1) |
int |
parse(java.lang.String text,
int offset)
Interpret the string and convert to Coo. |
boolean |
parsing(Parsing acoo)
Interpret the string and convert to Coo. |
void |
rotate_1(double[][] R)
Rotate a coordinate (apply a rotation to the position) in reverse direction. |
void |
rotate(double[][] R)
Rotate a coordinate (apply a rotation to the position). |
static void |
rotateVector_1(double[][] R,
double[] v)
Reversely rotate a vector. |
static void |
rotateVector(double[][] R,
double[] v)
Rotate a vector. |
void |
set()
Sets the position to its default (unknown) |
void |
set(Coo coo)
Set the position from an existing one. |
void |
set(double lon,
double lat)
Set a position from its longitude and latitude (RA/Dec). |
void |
set(double x,
double y,
double z)
Set a position from its unit vectors. |
void |
set(java.lang.String text)
Define a non-equatorial coordinate from its text (RA is in degrees) |
static int |
setDecimals(int nd)
Set (and get) the number of decimals for the default edition of the cordinates. |
static void |
setUvec(double lon,
double lat,
double[] u)
Compute the unit vector from angles in degrees. |
double |
sub(double[] du)
Subtraction of a vector (subtravtion, then normalisation) |
static double |
sub(double[] u,
double[] du)
Subtraction of a vector (subtravtion, then normalisation) |
java.lang.String |
toString()
Default Edition of the Coordinates, as 2 numbers expressing the angles in degrees. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public double x
public double y
public double z
public static Editing ed
public static int decimals
public static double[][] Umatrix3
Constructor Detail |
---|
public Coo()
public Coo(double lon, double lat)
lon
- longitude angle in degreeslat
- latitude angle in degreespublic Coo(double x, double y, double z)
x
- x item in unit vector (direction cosines)y
- y item in unit vector (direction cosines)z
- z item in unit vector (direction cosines)public Coo(java.lang.String text) throws java.text.ParseException
text
- a position as a string
java.text.ParseException
- when the string is not interpretableMethod Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public void set()
public void set(Coo coo)
coo
- the coordinatespublic static final void setUvec(double lon, double lat, double[] u)
lon
- longitude in degreeslat
- latitude angle in degreesu
- resulting unit vectorpublic void set(double lon, double lat)
lon
- longitude in degreeslat
- latitude angle in degreespublic void set(double x, double y, double z)
x
- x item in unit vector (direction cosines)y
- y item in unit vector (direction cosines)z
- z item in unit vector (direction cosines)public boolean parsing(Parsing acoo)
acoo
- a text ready for parsing
(may contain the hms or °'" characters)
public int parse(java.lang.String text, int offset)
text
- a text containing 2 angles, in decimal or Sexagesimal
(may contain the hms or °'" characters)offset
- where to start the analysis
public void set(java.lang.String text) throws java.text.ParseException
text
- a text containing 2 angles, in decimal or Sexagesimal
java.text.ParseException
- when the string is not interpretablepublic double getLon()
public double getLat()
public void copyAngles(double[] o)
public void copyUvector(double[] u)
public static final double distance(double lon1, double lat1, double lon2, double lat2)
lon1
- longitude of first point in degreeslat1
- latitude of first point in degreeslon2
- longitude of second point in degreeslat2
- latitude of second point in degrees
public final double distance(Coo pos)
pos
- another position on the sphere
public static final void rotateVector(double[][] R, double[] v)
R
- [3][3] Rotation Matrixv
- Vector to rotate, may be of dimension 3 or 6.public static final void rotateVector_1(double[][] R, double[] v)
R
- [3][3] Rotation Matrixv
- Vector to rotate, may be of dimension 3 or 6.public void rotate(double[][] R)
R
- [3][3] Rotation Matrixpublic void rotate_1(double[][] R)
R
- [3][3] Rotation Matrixpublic static double[][] eulerMatrix(double z, double theta, double zeta)
z
- Euler angletheta
- Euler anglezeta
- Euler angles
R = R_z(-z) · R_y(theta) · R_z(-zeta) |cos.z -sin.z 0| |cos.the 0 -sin.the| |cos.zet -sin.zet 0| = |sin.z cos.z 0| x | 0 1 0 | x |sin.zet cos.zet 0| | 0 0 1| |sin.the 0 cos.the| | 0 0 1|
public static final double[][] localMatrix(double lon, double lat)
+- -+ +- -+ | cosb.cosl cosb.sinl sinb | | x y z | | -sinl cosl 0 | = | (-y/r) (x/r) 0 | |-sinb.cosl -sinb.sinl cosb | |-z(x/r) z(-y/r) r | +- -+ +- -+r = sqrt(x*x+y*y) ; if r==0,take (x/r)=1, (y/r)=0
lon
- longitude of the center of local framelat
- latitude of the center of local frame
public final void localMatrix(double[][] R)
R
- = Rotation Matrix[3][3] to transform the current position
into (0,0)public final double[][] localMatrix()
public final double[][] moveMatrix(Coo coo2)
coo2
- target direction.
public static final double normalize(double[] u)
u
- 3- or 6-Vector to normalize
public double normalize()
public static final double add(double[] u, double[] du)
u
- 3- or 6-Vector to modifydu
- 3-Vector to add
public static final double sub(double[] u, double[] du)
u
- 3- or 6-Vector to modifydu
- 3-Vector to subtract
public final double add(double[] du)
du
- 3-Vector to add
public final double sub(double[] du)
du
- 3-Vector to subtract
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Object to compare
public final java.lang.StringBuffer editCoo(java.lang.StringBuffer b, int nd)
b
- the StringBuffer for editionnd
- the number of decimals in the edition of each coordinate.
Possible to use a negative nd to minimize the length.
public java.lang.StringBuffer edit(java.lang.StringBuffer b, int nd)
b
- the StringBuffer for editionnd
- the number of decimals in the edition of each coordinate.
Possible to use a negative nd to minimize the length.
public static int setDecimals(int nd)
nd
- the number of decimals in the edition of each coordinate.
Possible to use a negative nd to minimize the length.
public java.lang.String toString()
toString
in class java.lang.Object
public void dump(java.lang.String title)
title
- A title to precede the dump
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |