# PEARL Procedures: pearl-vector-operations.ipf Source File

pearl-vector-operations.ipf
Go to the documentation of this file.
#pragma rtGlobals=3
#pragma version = 2.1
#pragma IgorVersion = 6.1
#pragma ModuleName = PearlVectorOperations
// copyright (c) 2011-17 Paul Scherrer Institut
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http:///www.apache.org/licenses/LICENSE-2.0
//
// Please acknowledge the use of this code.
function rotate2d_x(xx, yy, angle)
variable xx, yy
variable angle
return xx * cos(angle * pi / 180) - yy * sin(angle * pi / 180)
end
function rotate2d_y(xx, yy, angle)
variable xx, yy
variable angle
return xx * sin(angle * pi / 180) + yy * cos(angle * pi / 180)
end
function /wave create_rotation_matrix_free()
make /n=(3,3)/free matrix
matrix = p == q // identity
return matrix
end
function /wave set_rotation_x(matrix, angle)
wave matrix
variable angle
variable si = sin(angle * pi / 180)
variable co = cos(angle * pi / 180)
matrix[1][1] = co
matrix[2][2] = co
matrix[2][1] = si
matrix[1][2] = -si
return matrix
end
function /wave set_rotation_y(matrix, angle)
wave matrix
variable angle
variable si = sin(angle * pi / 180)
variable co = cos(angle * pi / 180)
matrix[0][0] = co
matrix[2][2] = co
matrix[0][2] = si
matrix[2][0] = -si
return matrix
end
function /wave set_rotation_z(matrix, angle)
wave matrix
variable angle
variable si = sin(angle * pi / 180)
variable co = cos(angle * pi / 180)
matrix[0][0] = co
matrix[1][1] = co
matrix[1][0] = si
matrix[0][1] = -si
return matrix
end
function rotate_x_wave(inout, angle)
wave inout
variable angle
wave m_rotation_x = create_rotation_matrix_free()
make /n=3/d/free w_temp_rotate_x
variable ivec, nvec
nvec = max(DimSize(inout, 1), 1)
for (ivec = 0; ivec < nvec; ivec += 1)
set_rotation_x(m_rotation_x, angle)
w_temp_rotate_x = inout[p][ivec]
matrixop /free w_temp_rotate_x_result = m_rotation_x x w_temp_rotate_x
inout[0,2][ivec] = w_temp_rotate_x_result[p]
endfor
end
function rotate_y_wave(inout, angle)
wave inout
variable angle
wave m_rotation_y = create_rotation_matrix_free()
make /n=3/d/free w_temp_rotate_y
variable ivec, nvec
nvec = max(DimSize(inout, 1), 1)
for (ivec = 0; ivec < nvec; ivec += 1)
set_rotation_y(m_rotation_y, angle)
w_temp_rotate_y = inout[p][ivec]
matrixop /free w_temp_rotate_y_result = m_rotation_y x w_temp_rotate_y
inout[0,2][ivec] = w_temp_rotate_y_result[p]
endfor
end
function rotate_z_wave(inout, angle)
wave inout
variable angle
wave m_rotation_z = create_rotation_matrix_free()
make /n=3/d/free w_temp_rotate_z
variable ivec, nvec
nvec = max(DimSize(inout, 1), 1)
for (ivec = 0; ivec < nvec; ivec += 1)
set_rotation_z(m_rotation_z, angle)
w_temp_rotate_z = inout[p][ivec]
matrixop /free w_temp_rotate_z_result = m_rotation_z x w_temp_rotate_z
inout[0,2][ivec] = w_temp_rotate_z_result[p]
endfor
end
set_rotation_x
wave set_rotation_x(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the x axis.
Definition: pearl-vector-operations.ipf:92
rotate_x_wave
variable rotate_x_wave(wave inout, variable angle)
rotate a wave of 3-vectors about the x axis.
Definition: pearl-vector-operations.ipf:175
rotate2d_x
variable rotate2d_x(variable xx, variable yy, variable angle)
rotate a 2D cartesian vector and returns its x component.
Definition: pearl-vector-operations.ipf:45
set_rotation_z
wave set_rotation_z(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the z axis
Definition: pearl-vector-operations.ipf:148
rotate_y_wave
variable rotate_y_wave(wave inout, variable angle)
rotates a wave of 3-vectors about the y axis
Definition: pearl-vector-operations.ipf:203
rotate2d_y
variable rotate2d_y(variable xx, variable yy, variable angle)
rotate a 2D cartesian vector and returns its y component.
Definition: pearl-vector-operations.ipf:60
rotate_z_wave
variable rotate_z_wave(wave inout, variable angle)
rotates a wave of 3-vectors about the z axis
Definition: pearl-vector-operations.ipf:231
create_rotation_matrix_free
wave create_rotation_matrix_free()
create a free matrix wave which represents the 3-vector identity.
Definition: pearl-vector-operations.ipf:73
set_rotation_y
wave set_rotation_y(wave matrix, variable angle)
calculate a matrix representing a 3-vector rotation around the y axis
Definition: pearl-vector-operations.ipf:120