-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_affines.py
58 lines (42 loc) · 1.65 KB
/
find_affines.py
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
import numpy as np
from sklearn.linear_model import LinearRegression
v00 = [
0.30268568571622034,0.0,0.0,-0.5210486131988373,0.0,0.30268568571622034,0.0,-0.49323289091937955,0.0,0.0,0.30268568571622034,-0.046215261237895364
]
v01 = [
0.30268568571622034,0.0,0.0,-1.5243930948041884,0.0,0.30268568571622034,0.0,-0.5066108173407842,0.0,0.0,0.30268568571622034,-0.046215261237895364
]
v02 = [
0.30268568571622034,0.0,0.0,-2.5227208540015127,0.0,0.30268568571622034,0.0,-0.5283499477755668,0.0,0.0,0.30268568571622034,-0.046215261237895364
]
v03 = [
0.30268568571622034,0.0,0.0,-3.5544934292523487,0.0,0.30268568571622034,0.0,-0.49323289091937955,0.0,0.0,0.30268568571622034,-0.046215261237895364
]
v10 = [
0.30268568571622034,0.0,0.0,-0.4942927603560279,0.0,0.30268568571622034,0.0,-1.5066108173407844,0.0,0.0,0.30268568571622034,-0.046215261237895364
]
v20 = [
0.30268568571622034,0.0,0.0,-0.465864666710543,0.0,0.30268568571622034,0.0,-2.5517613190130253,0.0,0.0,0.30268568571622034,-0.046215261237895364
]
v30 = [
0.30268568571622034,0.0,0.0,-0.4842593155399744,0.0,0.30268568571622034,0.0,-3.5383833925916206,0.0,0.0,0.30268568571622034,-0.046215261237895364
]
def fit_line(v_index):
x = np.arange(4)
if v_index == 0:
views = [v00, v01, v02, v03]
view_index = 3
else:
views = [v00, v10, v20, v30]
view_index = 7
y = np.array([view[view_index] for view in views])
# print(x)
# print(y)
reg = LinearRegression().fit(x.reshape(-1, 1), y)
print("a, b =", reg.coef_[0], reg.intercept_)
if __name__ == '__main__':
print("X-coefficeints:")
fit_line(0)
print()
print("Y-coefficeints:")
fit_line(1)