PEARL Procedures rev-distro-3.1.0-0-gea838b3-dirty
Igor procedures for the analysis of PEARL data
Loading...
Searching...
No Matches
pearl-vector-operations.ipf
Go to the documentation of this file.
1#pragma TextEncoding = "UTF-8"
2#pragma rtGlobals=3
3#pragma version = 2.2
4#pragma IgorVersion = 6.1
5#pragma ModuleName = PearlVectorOperations
6
7// copyright (c) 2011-21 Paul Scherrer Institut
8//
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12// http:///www.apache.org/licenses/LICENSE-2.0
13//
14// Please acknowledge the use of this code.
15
31
36
37
46function rotate2d_x(xx, yy, angle)
47 variable xx, yy
48 variable angle
49
50 return xx * cos(angle * pi / 180) - yy * sin(angle * pi / 180)
51end
52
61function rotate2d_y(xx, yy, angle)
62 variable xx, yy
63 variable angle
64
65 return xx * sin(angle * pi / 180) + yy * cos(angle * pi / 180)
66end
67
75 make /n=(3,3)/free matrix
76 matrix = p == q // identity
77 return matrix
78end
79
93function /wave set_rotation_x(matrix, angle)
94 wave matrix
95 variable angle
96
97 variable si = sin(angle * pi / 180)
98 variable co = cos(angle * pi / 180)
99
100 matrix[1][1] = co
101 matrix[2][2] = co
102 matrix[2][1] = si
103 matrix[1][2] = -si
104
105 return matrix
106end
107
121function /wave set_rotation_y(matrix, angle)
122 wave matrix
123 variable angle
124
125 variable si = sin(angle * pi / 180)
126 variable co = cos(angle * pi / 180)
127
128 matrix[0][0] = co
129 matrix[2][2] = co
130 matrix[0][2] = si
131 matrix[2][0] = -si
132
133 return matrix
134end
135
149function /wave set_rotation_z(matrix, angle)
150 wave matrix
151 variable angle
152
153 variable si = sin(angle * pi / 180)
154 variable co = cos(angle * pi / 180)
155
156 matrix[0][0] = co
157 matrix[1][1] = co
158 matrix[1][0] = si
159 matrix[0][1] = -si
160
161 return matrix
162end
163
176function rotate_x_wave(inout, angle)
177 wave inout
178 variable angle
179
180 wave m_rotation = create_rotation_matrix_free()
181 set_rotation_x(m_rotation, angle)
182
183 duplicate /free inout, out
184 out = 0
185 variable j
186 for (j = 0; j < 3; j += 1)
187 out += m_rotation[p][j] * inout[j][q]
188 endfor
189
190 inout = out
191end
192
205function rotate_y_wave(inout, angle)
206 wave inout
207 variable angle
208
209 wave m_rotation = create_rotation_matrix_free()
210 set_rotation_y(m_rotation, angle)
211
212 duplicate /free inout, out
213 out = 0
214 variable j
215 for (j = 0; j < 3; j += 1)
216 out += m_rotation[p][j] * inout[j][q]
217 endfor
218
219 inout = out
220end
221
234function rotate_z_wave(inout, angle)
235 wave inout
236 variable angle
237
238 wave m_rotation = create_rotation_matrix_free()
239 set_rotation_z(m_rotation, angle)
240
241 duplicate /free inout, out
242 out = 0
243 variable j
244 for (j = 0; j < 3; j += 1)
245 out += m_rotation[p][j] * inout[j][q]
246 endfor
247
248 inout = out
249end
variable rotate_z_wave(wave inout, variable angle)
rotates a wave of 3-vectors about the z axis
variable rotate2d_y(variable xx, variable yy, variable angle)
rotate a 2D cartesian vector and returns its y component.
wave create_rotation_matrix_free()
create a free matrix wave which represents the 3-vector identity.
wave set_rotation_z(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the z axis
wave set_rotation_x(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the x axis.
variable rotate2d_x(variable xx, variable yy, variable angle)
rotate a 2D cartesian vector and returns its x component.
variable rotate_x_wave(wave inout, variable angle)
rotate a wave of 3-vectors about the x axis.
variable rotate_y_wave(wave inout, variable angle)
rotates a wave of 3-vectors about the y axis
wave set_rotation_y(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the y axis