WARPXM v1.10.0
Loading...
Searching...
No Matches
geometry.h
Go to the documentation of this file.
1#ifndef GEOMETRY_H
2#define GEOMETRY_H
3
4#include "apps/wmapplication.h" // for solverVariables_t
5
6inline void rotate_vector(const real v[3], const solverVariables_t* pSV, real Rv[3])
7{
8
9 Rv[0] = pSV->R[0][0] * v[0] + pSV->R[0][1] * v[1] + pSV->R[0][2] * v[2];
10 Rv[1] = pSV->R[1][0] * v[0] + pSV->R[1][1] * v[1] + pSV->R[1][2] * v[2];
11 Rv[2] = pSV->R[2][0] * v[0] + pSV->R[2][1] * v[1] + pSV->R[2][2] * v[2];
12}
13
14inline void antirotate_vector(const real Rv[3], const solverVariables_t* pSV, real v[3])
15{
16 v[0] = pSV->R[0][0] * Rv[0] + pSV->R[1][0] * Rv[1] + pSV->R[2][0] * Rv[2];
17 v[1] = pSV->R[0][1] * Rv[0] + pSV->R[1][1] * Rv[1] + pSV->R[2][1] * Rv[2];
18 v[2] = pSV->R[0][2] * Rv[0] + pSV->R[1][2] * Rv[1] + pSV->R[2][2] * Rv[2];
19}
20
21inline void rotate_matrix(const real* m[3], const solverVariables_t* pSV, real* RmRT[3])
22{
23 // RmRT = R \cdot m \cdot R^T
24 real val;
25 for (int i = 0; i < 3; i++)
26 {
27 for (int j = 0; j < 3; j++)
28 {
29 val = 0.;
30 for (int k = 0; k < 3; k++)
31 {
32 for (int l = 0; l < 3; l++)
33 {
34 val += pSV->R[i][k] * m[k][l] * pSV->R[j][l];
35 }
36 }
37 RmRT[i][j] = val;
38 }
39 }
40}
41
42inline void
43antirotate_matrix(const real* RmRT[3], const solverVariables_t* pSV, real* m[3])
44{
45 // m = R^T \cdot RmRT \cdot R
46 real val;
47 for (int i = 0; i < 3; i++)
48 {
49 for (int j = 0; j < 3; j++)
50 {
51 val = 0.;
52 for (int k = 0; k < 3; k++)
53 {
54 for (int l = 0; l < 3; l++)
55 {
56 val += pSV->R[k][i] * RmRT[k][l] * pSV->R[l][j];
57 }
58 }
59 m[i][j] = val;
60 }
61 }
62}
63
64inline real dot_product(const real* v)
65{
66 return (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
67}
68
69inline real dot_product(const real* u, const real* v)
70{
71 return (u[0] * v[0] + u[1] * v[1] + u[2] * v[2]);
72}
73
74inline real dot_product(const real x, const real y, const real z)
75{
76 return (x * x + y * y + z * z);
77}
78
79inline real dot_product(const real x1,
80 const real y1,
81 const real z1,
82 const real x2,
83 const real y2,
84 const real z2)
85{
86 return (x1 * x2 + y1 * y2 + z1 * z2);
87}
88
89inline real levi_civita(size_t a, size_t b, size_t c)
90{
91 if (a == b || b == c || c == a)
92 {
93 return 0;
94 }
95 else if (b == (a + 1) || c == (b + 1) || a == (c + 1))
96 {
97 return 1;
98 }
99 return -1;
100}
101
102#endif // GEOMETRY_H
void antirotate_matrix(const real *RmRT[3], const solverVariables_t *pSV, real *m[3])
Definition: geometry.h:43
real levi_civita(size_t a, size_t b, size_t c)
Definition: geometry.h:89
real dot_product(const real *v)
Definition: geometry.h:64
void rotate_vector(const real v[3], const solverVariables_t *pSV, real Rv[3])
Definition: geometry.h:6
void rotate_matrix(const real *m[3], const solverVariables_t *pSV, real *RmRT[3])
Definition: geometry.h:21
void antirotate_vector(const real Rv[3], const solverVariables_t *pSV, real v[3])
Definition: geometry.h:14
Definition: wmapplication.h:38
real R[3][3]
Definition: wmapplication.h:43
#define real
Definition: wmoclunstructuredreconstruction.h:11