1 #ifndef __PGS_EULER_H__
2 #define __PGS_EULER_H__
3 
4 #include "point.h"
5 
6 /*
7  * Euler transformation declarations
8  */
9 
10 /*
11  * Data structure of spherical (Euler) transformation.
12  */
13 typedef struct
14 {
15 	unsigned char	phi_a:2,	/* first axis */
16 					theta_a:2,	/* second axis */
17 					psi_a:2;	/* third axis */
18 	float8			phi,		/* first rotation angle */
19 					theta,		/* second rotation angle */
20 					psi;		/* third rotation angle */
21 } SEuler;
22 
23 
24 /*
25  * Transforms a spherical point and returns the pointer to a transformed spherical
26  * point.
27  */
28 void	euler_spoint_trans(SPoint *out, const SPoint *in, const SEuler *se);
29 
30 /*
31  * Transforms a spherical vector from 'spb' to 'spe' into an Euler transformation.
32  * Returns true if the transformation was successful.
33  */
34 bool	spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe);
35 
36 /*
37  * Sets the axes of transformation to ZXZ.
38  */
39 void	seuler_set_zxz(SEuler *se);
40 
41 /*
42  * Checks equality of two transformations.
43  */
44 bool	strans_eq(const SEuler *e1, const SEuler *e2);
45 
46 /*
47  * Transforms a vector using an Euler transformation. Returns the pointer to
48  * the result vector.
49  */
50 void	euler_vector_trans(Vector3D *out, const Vector3D *in, const SEuler *se);
51 
52 /*
53  * Inverts an Euler transformation. Returns the pointer to the
54  * inverted transformation.
55  */
56 void	spheretrans_inverse(SEuler *se_out, const SEuler *se_in);
57 
58 /*
59  * Inverts an Euler transformation replacing the original Euler transformation.
60  * Returns the pointer to the inverted transformation.
61  */
62 void	spheretrans_inv(SEuler *se);
63 
64 /*
65  * Converts an Euler transformation to a ZXZ-axis transformation. Returns
66  * the pointer to the converted transformation.
67  */
68 void	strans_zxz(SEuler *ret, const SEuler *se);
69 
70 /*
71  * Transforms an Euler transformation 'in' into 'out' using 'se'. The result
72  * is always a ZXZ-axis transformation. Returns the pointer to the transformed
73  * transformation.
74  */
75 void	seuler_trans_zxz(SEuler *out, const SEuler *in, const SEuler *se);
76 
77 /*
78  * Input of an Euler transformation.
79  */
80 Datum	spheretrans_in(PG_FUNCTION_ARGS);
81 
82 /*
83  * Input of an Euler transformation with axis Z,X,Z from three angles
84  * (phi, theta, psi) in radians.
85  */
86 Datum	spheretrans_from_float8(PG_FUNCTION_ARGS);
87 
88 /*
89  * Returns the first angle of an Euler transformation in radians.
90  */
91 Datum	spheretrans_phi(PG_FUNCTION_ARGS);
92 
93 /*
94  * Returns the second angle of an Euler transformation in radians.
95  */
96 Datum	spheretrans_theta(PG_FUNCTION_ARGS);
97 
98 /*
99  * Returns the third angle of an Euler transformation in radians.
100  */
101 Datum	spheretrans_psi(PG_FUNCTION_ARGS);
102 
103 /*
104  * Returns the axis of an Euler transformation as three letter code.
105  */
106 Datum	spheretrans_type(PG_FUNCTION_ARGS);
107 
108 /*
109  * Returns the Euler transformation (does nothing). This function is needed
110  * for +strans operator.
111  */
112 Datum	spheretrans(PG_FUNCTION_ARGS);
113 
114 /*
115  * Returns the inverse Euler transformation.
116  */
117 Datum	spheretrans_invert(PG_FUNCTION_ARGS);
118 
119 /*
120  * Convert an Euler transformation to a ZXZ-axis transformation.
121  */
122 Datum	spheretrans_zxz(PG_FUNCTION_ARGS);
123 
124 /*
125  * This function creates an Euler transformation from 3 angle values in
126  * radians and three letter code used for axes. A letter can be X, Y or Z
127  * (case-insensitive).
128  */
129 Datum	spheretrans_from_float8_and_type(PG_FUNCTION_ARGS);
130 
131 /*
132  * Checks equality of two Euler transformations.
133  */
134 Datum	spheretrans_equal(PG_FUNCTION_ARGS);
135 
136 /*
137  * Checks inequality of two Euler transformations.
138  */
139 Datum	spheretrans_not_equal(PG_FUNCTION_ARGS);
140 
141 /*
142  * Transforms an Euler transformation.
143  */
144 Datum	spheretrans_trans(PG_FUNCTION_ARGS);
145 
146 /*
147  * Transforms inverse an Euler transformations.
148  */
149 Datum	spheretrans_trans_inv(PG_FUNCTION_ARGS);
150 
151 /*
152  * Transforms a spherical point.
153  */
154 Datum	spheretrans_point(PG_FUNCTION_ARGS);
155 
156 /*
157  * Perform inverse transformation of a spherical point.
158  */
159 Datum	spheretrans_point_inverse(PG_FUNCTION_ARGS);
160 
161 #endif
162