ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/g3sphere.h
Revision: 2.1
Committed: Wed Aug 12 23:07:59 2015 UTC (8 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Added Jan Wienold's evalglare to distribution

File Contents

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