PEARL Procedures  rev-distro-2.1.0-1-gb7390cb-dirty
Igor procedures for the analysis of PEARL data
pearl-vector-operations.ipf
Go to the documentation of this file.
1 #pragma rtGlobals=3
2 #pragma version = 2.1
3 #pragma IgorVersion = 6.1
4 #pragma ModuleName = PearlVectorOperations
5 
6 // copyright (c) 2011-17 Paul Scherrer Institut
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 // http:///www.apache.org/licenses/LICENSE-2.0
12 //
13 // Please acknowledge the use of this code.
14 
30 
35 
36 
45 function rotate2d_x(xx, yy, angle)
46  variable xx, yy
47  variable angle
48 
49  return xx * cos(angle * pi / 180) - yy * sin(angle * pi / 180)
50 end
51 
60 function rotate2d_y(xx, yy, angle)
61  variable xx, yy
62  variable angle
63 
64  return xx * sin(angle * pi / 180) + yy * cos(angle * pi / 180)
65 end
66 
74  make /n=(3,3)/free matrix
75  matrix = p == q // identity
76  return matrix
77 end
78 
92 function /wave set_rotation_x(matrix, angle)
93  wave matrix
94  variable angle
95 
96  variable si = sin(angle * pi / 180)
97  variable co = cos(angle * pi / 180)
98 
99  matrix[1][1] = co
100  matrix[2][2] = co
101  matrix[2][1] = si
102  matrix[1][2] = -si
103 
104  return matrix
105 end
106 
120 function /wave set_rotation_y(matrix, angle)
121  wave matrix
122  variable angle
123 
124  variable si = sin(angle * pi / 180)
125  variable co = cos(angle * pi / 180)
126 
127  matrix[0][0] = co
128  matrix[2][2] = co
129  matrix[0][2] = si
130  matrix[2][0] = -si
131 
132  return matrix
133 end
134 
148 function /wave set_rotation_z(matrix, angle)
149  wave matrix
150  variable angle
151 
152  variable si = sin(angle * pi / 180)
153  variable co = cos(angle * pi / 180)
154 
155  matrix[0][0] = co
156  matrix[1][1] = co
157  matrix[1][0] = si
158  matrix[0][1] = -si
159 
160  return matrix
161 end
162 
175 function rotate_x_wave(inout, angle)
176  wave inout
177  variable angle
178 
179  wave m_rotation_x = create_rotation_matrix_free()
180  make /n=3/d/free w_temp_rotate_x
181  variable ivec, nvec
182  nvec = max(DimSize(inout, 1), 1)
183  for (ivec = 0; ivec < nvec; ivec += 1)
184  set_rotation_x(m_rotation_x, angle)
185  w_temp_rotate_x = inout[p][ivec]
186  matrixop /free w_temp_rotate_x_result = m_rotation_x x w_temp_rotate_x
187  inout[0,2][ivec] = w_temp_rotate_x_result[p]
188  endfor
189 end
190 
203 function rotate_y_wave(inout, angle)
204  wave inout
205  variable angle
206 
207  wave m_rotation_y = create_rotation_matrix_free()
208  make /n=3/d/free w_temp_rotate_y
209  variable ivec, nvec
210  nvec = max(DimSize(inout, 1), 1)
211  for (ivec = 0; ivec < nvec; ivec += 1)
212  set_rotation_y(m_rotation_y, angle)
213  w_temp_rotate_y = inout[p][ivec]
214  matrixop /free w_temp_rotate_y_result = m_rotation_y x w_temp_rotate_y
215  inout[0,2][ivec] = w_temp_rotate_y_result[p]
216  endfor
217 end
218 
231 function rotate_z_wave(inout, angle)
232  wave inout
233  variable angle
234 
235  wave m_rotation_z = create_rotation_matrix_free()
236  make /n=3/d/free w_temp_rotate_z
237  variable ivec, nvec
238  nvec = max(DimSize(inout, 1), 1)
239  for (ivec = 0; ivec < nvec; ivec += 1)
240  set_rotation_z(m_rotation_z, angle)
241  w_temp_rotate_z = inout[p][ivec]
242  matrixop /free w_temp_rotate_z_result = m_rotation_z x w_temp_rotate_z
243  inout[0,2][ivec] = w_temp_rotate_z_result[p]
244  endfor
245 end
wave set_rotation_x(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the x axis.
variable rotate_x_wave(wave inout, variable angle)
rotate a wave of 3-vectors about the x axis.
variable rotate2d_x(variable xx, variable yy, variable angle)
rotate a 2D cartesian vector and returns its x component.
wave set_rotation_z(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the z axis
variable rotate_y_wave(wave inout, variable angle)
rotates a wave of 3-vectors about the y axis
variable rotate2d_y(variable xx, variable yy, variable angle)
rotate a 2D cartesian vector and returns its y component.
variable rotate_z_wave(wave inout, variable angle)
rotates a wave of 3-vectors about the z axis
wave create_rotation_matrix_free()
create a free matrix wave which represents the 3-vector identity.
wave set_rotation_y(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the y axis