| 1 |
greg |
2.2 |
/* RCSid $Id$ */ |
| 2 |
greg |
2.1 |
/* |
| 3 |
|
|
** Author: Christian Reetz ([email protected]) |
| 4 |
|
|
*/ |
| 5 |
|
|
#ifndef __G3SPHERE_H |
| 6 |
|
|
#define __G3SPHERE_H |
| 7 |
|
|
#ifndef M_PI |
| 8 |
|
|
#define M_PI 3.14159265358979323846 |
| 9 |
|
|
#endif |
| 10 |
|
|
|
| 11 |
|
|
#ifdef __cplusplus |
| 12 |
|
|
extern "C" { |
| 13 |
|
|
#endif |
| 14 |
|
|
|
| 15 |
|
|
#include "gbasic.h" |
| 16 |
|
|
#include "g3vector.h" |
| 17 |
|
|
|
| 18 |
|
|
|
| 19 |
|
|
/** |
| 20 |
|
|
*** Functions for doing some geometry on spheres. |
| 21 |
|
|
*** Subscripts in names indicates: "cc" cartesian coords,"sph" spherical |
| 22 |
|
|
*** coords, normalization on cart. coords ist done, "chk" checks are made. |
| 23 |
|
|
*** If the function name contains no subsript |
| 24 |
|
|
*** no checks are made and normalized cartesian coordinates are expected. |
| 25 |
|
|
*** All functions allow for "res" to be equivalent to some other param. |
| 26 |
|
|
*/ |
| 27 |
|
|
|
| 28 |
|
|
#define G3S_RAD 0 |
| 29 |
|
|
#define G3S_THETA 1 |
| 30 |
|
|
#define G3S_PHI 2 |
| 31 |
|
|
#define G3S_MY 1 |
| 32 |
|
|
#define G3S_MZ 2 |
| 33 |
|
|
|
| 34 |
|
|
#define G3S_RESCOPY(res,co) int copy = 0; \ |
| 35 |
|
|
if (res == co) { \ |
| 36 |
|
|
res = g3v_create(); \ |
| 37 |
|
|
copy = 1; \ |
| 38 |
|
|
} |
| 39 |
|
|
#define G3S_RESFREE(res,co) if (copy) { \ |
| 40 |
|
|
g3v_copy(co,res); \ |
| 41 |
|
|
g3v_free(res); \ |
| 42 |
|
|
res = co; \ |
| 43 |
|
|
} |
| 44 |
|
|
|
| 45 |
|
|
/* |
| 46 |
|
|
** Some transformation between coord. systems: |
| 47 |
|
|
** cc: Cartesian |
| 48 |
|
|
** sph: spherical |
| 49 |
|
|
** mtr: metrical spherical |
| 50 |
|
|
** tr: transversal spherical |
| 51 |
|
|
*/ |
| 52 |
|
|
g3Vec g3s_sphtocc(g3Vec res,g3Vec sph); |
| 53 |
|
|
g3Vec g3s_cctosph(g3Vec res,g3Vec cc); |
| 54 |
|
|
g3Vec g3s_sphwrap(g3Vec sph); |
| 55 |
|
|
g3Vec g3s_trwrap(g3Vec tr); |
| 56 |
|
|
g3Vec g3s_mtrtocc(g3Vec res,g3Vec mtr); |
| 57 |
|
|
g3Vec g3s_cctomtr(g3Vec res,g3Vec cc); |
| 58 |
|
|
g3Vec g3s_trtocc(g3Vec res,g3Vec mtr); |
| 59 |
|
|
g3Vec g3s_cctotr(g3Vec res,g3Vec cc); |
| 60 |
|
|
g3Vec g3s_sphtotr(g3Vec res,g3Vec sph); |
| 61 |
|
|
g3Vec g3s_trtosph(g3Vec res,g3Vec tr); |
| 62 |
|
|
g3Float g3s_dist(const g3Vec cc1,const g3Vec cc2); |
| 63 |
|
|
g3Float g3s_dist_norm(const g3Vec cc1,const g3Vec cc2); |
| 64 |
|
|
|
| 65 |
|
|
|
| 66 |
|
|
#ifdef __cplusplus |
| 67 |
|
|
} |
| 68 |
|
|
#endif |
| 69 |
|
|
|
| 70 |
|
|
#endif |