|
||||||||
| 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 |
protected double |
lat
Latitude in degrees, range [-90, +90] |
protected double |
lon
Longitude in degrees, range [0, 360[ |
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(Coo coo)
Define a coordinate from another one (clone). |
|
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) |
double |
angle(Coo pos1,
Coo pos2)
Angle with 2 directions. |
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 |
dist2(Coo pos)
Squared distance between 2 points (= 4.sin2(r/2)) |
double |
dist2(double[] u)
Squared distance between point and a vector |
static double |
dist2(double[] u,
double[] v)
Squared distance between 2 vectors |
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. |
double |
distc(Coo pos1,
Coo pos2)
Distance between a point and a circle (defined by 2 coordinates). |
double |
dotprod(Coo pos)
Compute the dot-product (scalar product) |
double |
dotprod(double[] v)
Compute the dot-product (scalar product) |
static double |
dotprod(double[] v1,
double[] v2)
Compute the dot-product (scalar product) |
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. |
int |
hashCode()
Compute the hashcode |
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. |
static double |
norm2(double[] v1)
Compute the square norm of a vector |
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. |
static Coo |
perpendicular(Coo pos1,
Coo pos2)
Define a coordinate as the direct perpendicular to 2 positions. |
double |
posAngle(Coo pos)
Position angle (wrt North) of point (range 0-180). |
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. |
protected static java.lang.String |
toString(double[] u)
Edition of the 3 components of a vector. |
protected static java.lang.String |
toString(java.lang.String title,
double[] u)
Edition of the 3 components of a vector. |
protected static java.lang.String |
toString(java.lang.String title,
double[][] m)
Edition of a 3x3 matrix |
void |
vecprod(Coo pos,
double[] r)
Compute the vectorial product (result in vector r) |
void |
vecprod(double[] v,
double[] r)
Compute the vectorial product (result in vector r) |
static void |
vecprod(double[] v1,
double[] v2,
double[] r)
Compute the vectorial product (result in vector r) |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public double x
public double y
public double z
protected double lon
protected double lat
public static Editing ed
public static int decimals
public static double[][] Umatrix3
| Constructor Detail |
|---|
public Coo()
public Coo(Coo coo)
coo - the coordinates to clone.
public Coo(double lon,
double lat)
lon - longitude angle in degreeslat - latitude angle in degrees
public 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 interpretable| Method Detail |
|---|
public java.lang.Object clone()
clone in class java.lang.Objectpublic void set()
public void set(Coo coo)
coo - the coordinates
public static final void setUvec(double lon,
double lat,
double[] u)
lon - longitude in degreeslat - latitude angle in degreesu - resulting unit vector
public void set(double lon,
double lat)
lon - longitude in degreeslat - latitude angle in degrees
public 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 static Coo perpendicular(Coo pos1,
Coo pos2)
pos1 - first positionpos2 - second position
public boolean parsing(Parsing acoo)
acoo - a text ready for parsing
(may contain the hms or {deg}'" 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 {deg}'" 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 dist2(Coo pos)
pos - another position on the sphere
public final double dist2(double[] u)
u - a 3-vector
public static final double dist2(double[] u,
double[] v)
u - a 3-vectorv - a 3-vector
public final double distance(Coo pos)
pos - another position on the sphere
public final double distc(Coo pos1,
Coo pos2)
pos1 - First point defining the circlepos2 - Second point defining the circle
public final double angle(Coo pos1,
Coo pos2)
pos1 - First point Apos2 - Second point B
public final double posAngle(Coo pos)
pos - Point
public static final double dotprod(double[] v1,
double[] v2)
v1 - first vectorv2 - second vector
public final double dotprod(double[] v)
v - second vector
public final double dotprod(Coo pos)
pos - second vector
public static final double norm2(double[] v1)
v1 - the vector
public static final void vecprod(double[] v1,
double[] v2,
double[] r)
v1 - first vectorv2 - second vectorr - the returned resulting vector
public final void vecprod(double[] v,
double[] r)
v - second vectorr - the returned resulting vector r = this ^ v
public final void vecprod(Coo pos,
double[] r)
pos - second vectorr - the returned resulting vector r = this ^ v
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 Matrix
public 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.Objecto - Object to compare
public int hashCode()
hashCode in class java.lang.Object
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.Objectprotected static final java.lang.String toString(double[] u)
u - the 3-vector
protected static final java.lang.String toString(java.lang.String title,
double[] u)
title - text prefixing each line.u - the 3-vector
protected static final java.lang.String toString(java.lang.String title,
double[][] m)
title - text prefixing each line of the matrixm - the 3x3 matrix
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 | |||||||