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

pearl-vector-operations.ipf
Go to the documentation of this file.
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3
#pragma version = 2.2
#pragma IgorVersion = 6.1
#pragma ModuleName = PearlVectorOperations
// copyright (c) 2011-21 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 = create_rotation_matrix_free()
set_rotation_x(m_rotation, angle)
duplicate /free inout, out
out = 0
variable j
for (j = 0; j < 3; j += 1)
out += m_rotation[p][j] * inout[j][q]
endfor
inout = out
end
function rotate_y_wave(inout, angle)
wave inout
variable angle
wave m_rotation = create_rotation_matrix_free()
set_rotation_y(m_rotation, angle)
duplicate /free inout, out
out = 0
variable j
for (j = 0; j < 3; j += 1)
out += m_rotation[p][j] * inout[j][q]
endfor
inout = out
end
function rotate_z_wave(inout, angle)
wave inout
variable angle
wave m_rotation = create_rotation_matrix_free()
set_rotation_z(m_rotation, angle)
duplicate /free inout, out
out = 0
variable j
for (j = 0; j < 3; j += 1)
out += m_rotation[p][j] * inout[j][q]
endfor
inout = out
end
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:205
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:121
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:93
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:46
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:74
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:176
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:61
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:234
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:149