-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-transfo.py
executable file
·97 lines (69 loc) · 1.59 KB
/
test-transfo.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
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import numpy as np
import scipy.optimize as opt
import matplotlib.pyplot as plt
from transfo import Transfo3D,OldTransfo3D
# test assuming mm
npts=20
xyz=np.zeros((3,npts))
xyz[0]=np.random.uniform(size=npts)*1000. # typical size is 1 m
xyz[1]=np.random.uniform(size=npts)*1000.
xyz[2]=np.random.uniform(size=npts)*1000.
#xyz[2]=2000.
dxyz=np.array([10,30,40])
print("test 1")
a=30.#deg
ca=np.cos(a/180*np.pi)
sa=np.sin(a/180*np.pi)
rot=np.array([[ca,sa,0],[-sa,ca,0],[0,0,1]])
xyz2 = rot.dot(xyz+dxyz[:,None])
t=Transfo3D()
rms=t.fit(xyz,xyz2)
print(t)
print("Transfo rms:",rms)
print("test 2")
a=-20.#deg
ca=np.cos(a/180*np.pi)
sa=np.sin(a/180*np.pi)
rot=np.array([[1,0,0],[0,ca,sa],[0,-sa,ca]])
xyz2 = rot.dot(xyz+dxyz[:,None])
t=Transfo3D()
rms=t.fit(xyz,xyz2)
print(t)
print("Transfo rms:",rms)
print("test 3")
a=10.#deg
ca=np.cos(a/180*np.pi)
sa=np.sin(a/180*np.pi)
rot=np.array([[ca,0,sa],[0,1,0],[-sa,0,ca]])
xyz2 = rot.dot(xyz+dxyz[:,None])
t=Transfo3D()
rms=t.fit(xyz,xyz2)
print(t)
print("Transfo rms:",rms)
print("test 4")
a=10.#deg
ca=np.cos(a/180*np.pi)
sa=np.sin(a/180*np.pi)
rot=rot.dot([[ca,0,sa],[0,1,0],[-sa,0,ca]])
xyz2 = rot.dot(xyz+dxyz[:,None])
xyz2[0] += 100.
xyz2[1] += 300.
xyz2[2] += 400.
t=Transfo3D()
rms=t.fit(xyz,xyz2)
print(t)
print("Transfo rms:",rms)
print("test 5")
a=30.#deg
ca=np.cos(a/180*np.pi)
sa=np.sin(a/180*np.pi)
rot=np.array([[ca,sa,0],[-sa,ca,0],[0,0,1]])
xyz2 = rot.dot(xyz+dxyz[:,None])
xyz2[0] = -xyz2[0] # change one sign
t=Transfo3D()
rms=t.fit(xyz,xyz2)
print(t)
print("Transfo rms:",rms)