Mercurial > hg > orthanc-stone
annotate OrthancStone/Resources/Computations/ComputeWarp.py @ 2114:c23eef785569
update year to 2024
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 24 Jan 2024 16:44:04 +0100 |
parents | 07964689cb0b |
children | 16c01cc201e7 |
rev | line source |
---|---|
193
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
3 # Stone of Orthanc |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
5 # Department, University Hospital of Liege, Belgium |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
6 # Copyright (C) 2017-2024 Osimis S.A., Belgium |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
7 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
8 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
9 # This program is free software: you can redistribute it and/or |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
10 # modify it under the terms of the GNU Lesser General Public License |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
11 # as published by the Free Software Foundation, either version 3 of |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
12 # the License, or (at your option) any later version. |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
13 # |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
14 # This program is distributed in the hope that it will be useful, but |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
15 # WITHOUT ANY WARRANTY; without even the implied warranty of |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
17 # Lesser General Public License for more details. |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
18 # |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
19 # You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
20 # License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1589
diff
changeset
|
21 # <http://www.gnu.org/licenses/>. |
1589
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
22 |
8c5f9864545f
adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
23 |
193
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 from sympy import * |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 from sympy.solvers import solve |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 import pprint |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import sys |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 init_printing(use_unicode=True) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 # Create a test 3D vector using homogeneous coordinates |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 x, y, z, w = symbols('x y z w') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 p = Matrix([ x, y, z, w ]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 # Create a shear matrix, and a scale/shift "T * S" transform as in |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 # Lacroute's thesis (Equation A.16, page 209) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 ex, ey, ew = symbols('ex ey ew') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 sx, sy, tx, ty = symbols('sx sy tx ty') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 TS = Matrix([[ sx, 0, 0, tx ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 [ 0, sy, 0, ty ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 [ 0, 0, 1, 0 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 [ 0, 0, 0, 1 ]]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 pureShear = Matrix([[ 1, 0, ex, 0 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 [ 0, 1, ey, 0 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 [ 0, 0, 1, 0 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 [ 0, 0, ew, 1 ]]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 # Create a general warp matrix, that corresponds to "M_warp" in |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 # Equation (A.17) of Lacroute's thesis: |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 ww11, ww12, ww13, ww14, ww21, ww22, ww23, ww24, ww31, ww32, ww33, ww34, ww41, ww42, ww43, ww44 = symbols('ww11 ww12 ww13 ww14 ww21 ww22 ww23 ww24 ww31 ww32 ww33 ww34 ww41 ww42 ww43 ww44') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 WW = Matrix([[ ww11, ww12, ww13, ww14 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 [ ww21, ww22, ww23, ww24 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 [ ww31, ww32, ww33, ww34 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 [ ww41, ww43, ww43, ww44 ]]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 # Create the matrix of intrinsic parameters of the camera |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 k11, k22, k14, k24 = symbols('k11 k22 k14 k24') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 K = Matrix([[ k11, 0, 0, k14 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 [ 0, k22, 0, k24 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 [ 0, 0, 0, 1 ]]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 # The full decomposition is: |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 M_shear = TS * pureShear |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 M_warp = K * WW * TS.inv() |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 AA = M_warp * M_shear |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 # Check that the central component "M_warp == K * WW * TS.inv()" that |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 # is the left part of "A" is another general warp matrix (i.e. no |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 # exception is thrown about incompatible matrix sizes): |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 M_warp * p |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 if (M_warp.cols != 4 or |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 M_warp.rows != 3): |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 raise Exception('Invalid matrix size') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 # We've just shown that "M_warp" is a general 3x4 matrix. Let's call |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 # it W: |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 w11, w12, w13, w14, w21, w22, w23, w24, w41, w42, w43, w44 = symbols('w11 w12 w13 w14 w21 w22 w23 w24 w41 w42 w43 w44') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 W = Matrix([[ w11, w12, w13, w14 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 [ w21, w22, w23, w24 ], |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 [ w41, w43, w43, w44 ]]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 # This shows that it is sufficient to study a decomposition of the |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 # following form: |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 A = W * M_shear |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 print('\nA = W * M_shear =') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 pprint.pprint(A) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 sys.stdout.write('\nW = ') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 pprint.pprint(W) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 sys.stdout.write('\nM_shear = ') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 pprint.pprint(M_shear) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 # Let's consider one fixed 2D point (i,j) in the intermediate |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 # image. The 3D points (x,y,z,1) that are mapped to (i,j) must satisfy |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 # the equation "(i,j) == M_shear * (x,y,z,w)". As "M_shear" is |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 # invertible, we solve "(x,y,z,w) == inv(M_shear) * (i,j,k,1)". |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 i, j, k = symbols('i j k') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 l = M_shear.inv() * Matrix([ i, j, k, 1 ]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 print('\nLocus for points imaged to some fixed (i,j,k,l) point in the intermediate image:') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 print('x = %s' % l[0]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 print('y = %s' % l[1]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 print('z = %s' % l[2]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 print('w = %s' % l[3]) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 # By inspecting the 4 equations above, we see that the locus entirely |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 # depends upon the "k" value that encodes the Z-axis |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 print('\nGlobal effect of the shear-warp transform on this locus:') |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 q = expand(A * l) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 pprint.pprint(q) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 print("\nWe can arbitrarily fix the value of 'k', so let's choose 'k=0':") |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 pprint.pprint(q.subs(k, 0)) |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 print("\nThis gives the warp transform.") |
4abddd083374
ShearWarpProjectiveTransform::ApplyAxial()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 print("QED: line after Equation (A.17) on page 209.\n") |