-
Notifications
You must be signed in to change notification settings - Fork 1
/
linear.h
51 lines (40 loc) · 1.38 KB
/
linear.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
#ifndef _LINEAR_H_
#define _LINEAR_H_
#include "common.h"
namespace Renzoku {
class Linear {
public:
static inline void
solve33(Float a, Float b, Float c,
Float d, Float e, Float f,
Float g, Float h, Float i,
Float p, Float q, Float r,
Float &x, Float &y, Float &z);
static inline Float
det(Float a, Float b, Float c,
Float d, Float e, Float f,
Float g, Float h, Float i);
};
inline void Linear::solve33(Float a, Float b, Float c,
Float d, Float e, Float f,
Float g, Float h, Float i,
Float p, Float q, Float r,
Float &x, Float &y, Float &z) {
Float inv_denom = 1.0f / det(a, b, c, d, e, f, g, h , i);
x = inv_denom * det(p, b, c,
q, e, f,
r, h, i);
y = inv_denom * det(a, p, c,
d, q, f,
g, r, i);
z = inv_denom * det(a, b, p,
d, e, q,
g, h, r);
}
inline Float Linear::det(Float a, Float b, Float c,
Float d, Float e, Float f,
Float g, Float h, Float i) {
return (a * e * i + b * f * g + c * d * h) - (c * e * g + b * d * i + a * f * h);
}
} // end namespace
#endif