Package cds.healpix.common.sphgeom
Class CooXYZ
- java.lang.Object
-
- cds.healpix.common.sphgeom.CooXYZ
-
- Direct Known Subclasses:
Cone
public class CooXYZ extends java.lang.Object
Defines a coordinates on the unit-sphere, internally both Euclidean and Spherical coordinates are stored. To solve the Minimum Enclosing Cone (MEC) problem, we use the same algorithm as in Berg et al. (2008) "Computational Geometry - Algorithms and Applications, 3rd Ed.pdf", see ยง4.7, p. 86-89 (), which principle is general and works well in the sphere as cited in Barequet & Elber (2005) "Optimal bounding cones of vectors in three dimensions" (https://www.sciencedirect.com/science/article/pii/S0020019004002911?via%3Dihub). It uses LP (linear programming) and performs in O(n), n being the number of points we want the smallest enclosing cone. The code and its documentation (for the case of the unit sphere) is originally part of the ARCHES x-match tool (developped by F.-X. Pineau for the European FP7 project ARCHES).- Author:
- F.-X. Pineau
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CooXYZ
arcCenter(CooXYZ a, CooXYZ b)
Returns the center of the arc define by the smallest distance (on the unit sphere) between the two given points.static CooXYZ
arcCenter(CooXYZ a, CooXYZ b, double r)
Faster version ofarcCenter(CooXYZ, CooXYZ)
when we already know the distance between the two given points.static Cone
boundingCone(CooXYZ... p)
Returns a bounding cone (not the smallest one, for the samllest one,mec(cds.healpix.common.sphgeom.CooXYZ, cds.healpix.common.sphgeom.CooXYZ)
).static CooXYZ
circumCenter(CooXYZ a, CooXYZ b, CooXYZ c)
Returns the center on the unit sphere of the circumcircle of a spherical triangle of given vertices a, b and c.static CooXYZ
circumCenter(CooXYZ a, CooXYZ b, CooXYZ c, double r)
Returns the center on the unit sphere of the circumcircle of radius r of a spherical triangle of given vertices a, b and c.static double
circumRadiusSphe(double a, double b, double c)
Returns the angular radius (in radians) of the circumcircle of a spherical triangle of given side lengths a, b and c.static double
circumRadiusSphe(CooXYZ a, CooXYZ b, CooXYZ c)
Returns the angular radius (in radians) of the circumcircle of a spherical triangle of given vertices a, b and c.static Vect3D
crossProd(CooXYZ v1, CooXYZ v2)
Returns the cross-product of the two given vectors.static double
euclDist(CooXYZ c1, CooXYZ c2)
Returns the Euclidean distance separating the two given points.static double
havDist(CooXYZ c1, CooXYZ c2)
Returns the spherival distance (using the Haversine formula) separating the two given points.double
lat()
Getterdouble
lon()
Getterstatic Cone
mec(CooXYZ... p)
Returns the Minimum Enclosing Cone, i.e.static Cone
mec(CooXYZ a, CooXYZ b)
Returns the minimum enclosing cone, i.e.static Cone
mec(CooXYZ a, CooXYZ b, CooXYZ c)
Returns the Minimum Enclosing Cone, i.e.static CooXYZ
normalizedSum(CooXYZ... vects)
Returns the sum of the given vector, normalized so that the resulting vector is on the unit sphere.double
scalarProd(CooXYZ v)
Computes the scalar product of this point with given vectors.double
scalarProd(Vect3D v)
Computes the scalar product of this point with given vectors.static double
spheDist(CooXYZ c1, CooXYZ c2)
Retruns the spherical distance separating the two given points.static CooXYZ
toEquaCooXYZ(CooXYZ pos)
java.lang.String
toString()
double
x()
Getterdouble
y()
Getterdouble
z()
Getter
-
-
-
Constructor Detail
-
CooXYZ
public CooXYZ(double lonRad, double latRad)
-
CooXYZ
public CooXYZ(double x, double y, double z)
-
CooXYZ
public CooXYZ(Vect3D v)
-
-
Method Detail
-
lon
public final double lon()
Getter- Returns:
- the longitude, in radians
-
lat
public final double lat()
Getter- Returns:
- the latitude, in radians
-
x
public final double x()
Getter- Returns:
- the x cartesian coordinate
-
y
public final double y()
Getter- Returns:
- the y cartesian coordinate
-
z
public final double z()
Getter- Returns:
- the z cartesian coordinate
-
normalizedSum
public static CooXYZ normalizedSum(CooXYZ... vects)
Returns the sum of the given vector, normalized so that the resulting vector is on the unit sphere.- Parameters:
vects
- vector we are looking for the normalized sum.- Returns:
- the sum of the given vector, normalized so that the resulting vector is on the unit sphere.
-
crossProd
public static Vect3D crossProd(CooXYZ v1, CooXYZ v2)
Returns the cross-product of the two given vectors.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- the cross-product of the two given vectors.
-
scalarProd
public double scalarProd(Vect3D v)
Computes the scalar product of this point with given vectors.- Parameters:
v
- the second vector used in the scalar product.- Returns:
- the scalar product of this point with given vectors.
-
scalarProd
public double scalarProd(CooXYZ v)
Computes the scalar product of this point with given vectors.- Parameters:
v
- the second vector used in the scalar product.- Returns:
- the scalar product of this point with given vectors.
-
havDist
public static final double havDist(CooXYZ c1, CooXYZ c2)
Returns the spherival distance (using the Haversine formula) separating the two given points.- Parameters:
c1
- first pointc2
- second point- Returns:
- the spherival distance (using the Haversine formula) separating the two given points.
-
spheDist
public static final double spheDist(CooXYZ c1, CooXYZ c2)
Retruns the spherical distance separating the two given points.- Parameters:
c1
- first pointc2
- second point- Returns:
- the spherical distance separating the two given points.
-
euclDist
public static final double euclDist(CooXYZ c1, CooXYZ c2)
Returns the Euclidean distance separating the two given points.- Parameters:
c1
- first pointc2
- second point- Returns:
- the Euclidean distance separating the two given points.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
boundingCone
public static Cone boundingCone(CooXYZ... p)
Returns a bounding cone (not the smallest one, for the samllest one,mec(cds.healpix.common.sphgeom.CooXYZ, cds.healpix.common.sphgeom.CooXYZ)
). In the worst case, the bounding cone has a radius ~= 2x the MEC radius.- Parameters:
p
-- Returns:
-
mec
public static Cone mec(CooXYZ a, CooXYZ b)
Returns the minimum enclosing cone, i.e. the cone containig the two given points and having the smallest possible radius. In this trivial case, the diameter of the cone is the arc (ab).- Parameters:
a
- first pointb
- secobd point- Returns:
- the minimum enclosing cone, i.e. the cone containig the two given points and having the smallest possible radius. In this trivial case, the diameter of the cone is the arc (ab).
-
mec
public static Cone mec(CooXYZ a, CooXYZ b, CooXYZ c)
Returns the Minimum Enclosing Cone, i.e. the cone containig the three given points and having the smallest possible radius.- Parameters:
a
- first pointb
- secobd pointc
- third point- Returns:
- the Minimum Enclosing Cone, i.e. the cone containig the three given points and having the smallest possible radius.
-
mec
public static Cone mec(CooXYZ... p)
Returns the Minimum Enclosing Cone, i.e. the cone containig all the given points and having the smallest possible radius. WARNING: the algorithm used here is not made to work with nonreflex cones (i.e. if the points are distributed is more than an hemisphere). For our purpose, we stop the algo AND RETURN NULL if we detect a radius > 7 rad ( i.e. ~97 deg) since below this value, the cell-in-cone or cell-in-polygone algorithm will test the 12 healpix base cells.- Parameters:
p
- list of the points we look for the minimum enclising cone- Returns:
- the Minimum Enclosing Cone, i.e. the cone containig all the given points and having the smallest possible radius.
-
circumRadiusSphe
public static final double circumRadiusSphe(double a, double b, double c)
Returns the angular radius (in radians) of the circumcircle of a spherical triangle of given side lengths a, b and c.- Parameters:
a
- first size length (in radians)b
- second size length (in radians)c
- third size length (in radians)- Returns:
- in the angular radius (in radians) of the circumcircle of a spherical triangle of given side lengths a, b and c.
-
circumRadiusSphe
public static final double circumRadiusSphe(CooXYZ a, CooXYZ b, CooXYZ c)
Returns the angular radius (in radians) of the circumcircle of a spherical triangle of given vertices a, b and c.- Parameters:
a
- first vertexb
- second vertexc
- third vertex- Returns:
- the angular radius (in radians) of the circumcircle of a spherical triangle of given vertices a, b and c.
-
circumCenter
public static final CooXYZ circumCenter(CooXYZ a, CooXYZ b, CooXYZ c)
Returns the center on the unit sphere of the circumcircle of a spherical triangle of given vertices a, b and c.- Parameters:
a
- first vertexb
- second vertexc
- third vertex- Returns:
- the center on the unit sphere of the circumcircle of a spherical triangle of given vertices a, b and c.
-
circumCenter
public static final CooXYZ circumCenter(CooXYZ a, CooXYZ b, CooXYZ c, double r)
Returns the center on the unit sphere of the circumcircle of radius r of a spherical triangle of given vertices a, b and c.- Parameters:
a
- first vertexb
- second vertexc
- third vertexr
- spherical radius of the circumcircle- Returns:
- the center on the unit sphere of the circumcircle of radius r of a spherical triangle of given vertices a, b and c.
-
arcCenter
public static final CooXYZ arcCenter(CooXYZ a, CooXYZ b)
Returns the center of the arc define by the smallest distance (on the unit sphere) between the two given points.- Parameters:
a
- first pointb
- second point- Returns:
- the center of the arc define by the smallest distance (on the unit sphere) between the two given points.
-
arcCenter
public static final CooXYZ arcCenter(CooXYZ a, CooXYZ b, double r)
Faster version ofarcCenter(CooXYZ, CooXYZ)
when we already know the distance between the two given points. INFO (2019/10/01 while porting in Rust): WE CAN SIMPLY COMPUTE THE NORMALIZED MEAN OF THE TWO VECTORS!!- Parameters:
a
- first pointb
- second pointr
- half the distance between a and b- Returns:
- the center of the arc define by the smallest distance (on the unit sphere, = 2*r) between the two given points.
-
-