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