distro release 2.1.1
This commit is contained in:
@ -1,41 +1,97 @@
|
||||
#pragma rtGlobals=3
|
||||
#pragma version = 2.0
|
||||
#pragma version = 2.1
|
||||
#pragma IgorVersion = 6.1
|
||||
#pragma ModuleName = PearlVectorOperations
|
||||
|
||||
// author: matthias.muntwiler@psi.ch
|
||||
// Copyright (c) 2011-13 Paul Scherrer Institut
|
||||
// $Id$
|
||||
// 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.
|
||||
|
||||
/// @file
|
||||
/// @brief basic vector geometry operations.
|
||||
/// @ingroup ArpesPackage
|
||||
///
|
||||
/// this procedure file contains basic vector geometry functions,
|
||||
/// such as rotations.
|
||||
///
|
||||
/// @author matthias muntwiler, matthias.muntwiler@psi.ch
|
||||
///
|
||||
/// @copyright 2011-17 Paul Scherrer Institut @n
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License"); @n
|
||||
/// you may not use this file except in compliance with the License. @n
|
||||
/// You may obtain a copy of the License at
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
|
||||
/// @namespace PearlVectorOperations
|
||||
/// @brief basic vector geometry operations.
|
||||
///
|
||||
/// PearlVectorOperations is declared in @ref pearl-vector-operations.ipf.
|
||||
|
||||
|
||||
/// rotate a 2D cartesian vector and returns its x component.
|
||||
///
|
||||
/// @param xx x coordinate.
|
||||
/// @param yy y coordinate.
|
||||
/// @param angle rotation angle in degrees.
|
||||
///
|
||||
/// @return x coordinate of the rotated vector.
|
||||
///
|
||||
function rotate2d_x(xx, yy, angle)
|
||||
// rotates a 2D cartesian vector and returns its x component
|
||||
variable xx, yy
|
||||
variable angle // rotation angle in degrees
|
||||
variable angle
|
||||
|
||||
return xx * cos(angle * pi / 180) - yy * sin(angle * pi / 180)
|
||||
end
|
||||
|
||||
/// rotate a 2D cartesian vector and returns its y component.
|
||||
///
|
||||
/// @param xx x coordinate.
|
||||
/// @param yy y coordinate.
|
||||
/// @param angle rotation angle in degrees.
|
||||
///
|
||||
/// @return y coordinate of the rotated vector.
|
||||
///
|
||||
function rotate2d_y(xx, yy, angle)
|
||||
// rotates a 2D cartesian vector and returns its y component
|
||||
variable xx, yy
|
||||
variable angle // rotation angle in degrees
|
||||
variable angle
|
||||
|
||||
return xx * sin(angle * pi / 180) + yy * cos(angle * pi / 180)
|
||||
end
|
||||
|
||||
/// create a free matrix wave which represents the 3-vector identity.
|
||||
///
|
||||
/// the matrix is initialized as identity.
|
||||
///
|
||||
/// @return 3x3 identity matrix in a free wave.
|
||||
///
|
||||
function /wave create_rotation_matrix_free()
|
||||
// creates a matrix which represents a 3-vector rotation
|
||||
// the matrix is initialized as identity
|
||||
|
||||
make /n=(3,3)/free matrix
|
||||
matrix = p == q // identity
|
||||
return matrix
|
||||
end
|
||||
|
||||
/// calculate a matrix representing a 3-vector rotation around the x axis.
|
||||
///
|
||||
/// the function calculates the matrix elements of a rotation about the x axis.
|
||||
///
|
||||
/// @param[in,out] matrix 3x3 wave to receive the rotation matrix elements.
|
||||
/// the function calculates only the 2x2 block of the rotation.
|
||||
/// the other elements must be initialized by the caller,
|
||||
/// e.g. set to the identity matrix.
|
||||
/// @param[in] angle rotation angle in degrees.
|
||||
///
|
||||
/// @return rotation matrix.
|
||||
/// this is the same wave instance as the matrix input.
|
||||
///
|
||||
function /wave set_rotation_x(matrix, angle)
|
||||
// calculates a matrix representing a 3-vector rotation around the x axis
|
||||
wave matrix // rotation matrix
|
||||
variable angle // rotation angle in degrees
|
||||
wave matrix
|
||||
variable angle
|
||||
|
||||
variable si = sin(angle * pi / 180)
|
||||
variable co = cos(angle * pi / 180)
|
||||
@ -48,10 +104,22 @@ function /wave set_rotation_x(matrix, angle)
|
||||
return matrix
|
||||
end
|
||||
|
||||
/// calculate a matrix representing a 3-vector rotation around the y axis
|
||||
///
|
||||
/// the function calculates the matrix elements of a rotation about the y axis.
|
||||
///
|
||||
/// @param[in,out] matrix 3x3 wave to receive the rotation matrix elements.
|
||||
/// the function calculates only the 2x2 block of the rotation.
|
||||
/// the other elements must be initialized by the caller,
|
||||
/// e.g. set to the identity matrix.
|
||||
/// @param[in] angle rotation angle in degrees.
|
||||
///
|
||||
/// @return rotation matrix.
|
||||
/// this is the same wave instance as the matrix input.
|
||||
///
|
||||
function /wave set_rotation_y(matrix, angle)
|
||||
// calculates a matrix representing a 3-vector rotation around the y axis
|
||||
wave matrix // rotation matrix
|
||||
variable angle // rotation angle in degrees
|
||||
wave matrix
|
||||
variable angle
|
||||
|
||||
variable si = sin(angle * pi / 180)
|
||||
variable co = cos(angle * pi / 180)
|
||||
@ -64,10 +132,22 @@ function /wave set_rotation_y(matrix, angle)
|
||||
return matrix
|
||||
end
|
||||
|
||||
/// calculate a matrix representing a 3-vector rotation around the z axis
|
||||
///
|
||||
/// the function calculates the matrix elements of a rotation about the z axis.
|
||||
///
|
||||
/// @param[in,out] matrix 3x3 wave to receive the rotation matrix elements.
|
||||
/// the function calculates only the 2x2 block of the rotation.
|
||||
/// the other elements must be initialized by the caller,
|
||||
/// e.g. set to the identity matrix.
|
||||
/// @param[in] angle rotation angle in degrees.
|
||||
///
|
||||
/// @return rotation matrix.
|
||||
/// this is the same wave instance as the matrix input.
|
||||
///
|
||||
function /wave set_rotation_z(matrix, angle)
|
||||
// calculates a matrix representing a 3-vector rotation around the z axis
|
||||
wave matrix // rotation matrix
|
||||
variable angle // rotation angle in degrees
|
||||
wave matrix
|
||||
variable angle
|
||||
|
||||
variable si = sin(angle * pi / 180)
|
||||
variable co = cos(angle * pi / 180)
|
||||
@ -80,11 +160,21 @@ function /wave set_rotation_z(matrix, angle)
|
||||
return matrix
|
||||
end
|
||||
|
||||
/// rotate a wave of 3-vectors about the x axis.
|
||||
///
|
||||
/// this function rotates multiple vectors.
|
||||
///
|
||||
/// @param[in,out] inout wave with dimensions (M, N), M >= 3 (x, y, z), N >= 1.
|
||||
/// the result will be in same wave.
|
||||
/// only the first three rows of dimension 0 are used,
|
||||
/// extra rows are left unchanged.
|
||||
/// @param[in] angle rotation angle in degrees.
|
||||
///
|
||||
/// @return none
|
||||
///
|
||||
function rotate_x_wave(inout, angle)
|
||||
// rotates a wave of 3-vectors about the x axis
|
||||
wave inout // wave with dimensions (3, N), N >= 1, (x, y, z)
|
||||
// result will be in same wave
|
||||
variable angle // rotation angle in degrees
|
||||
wave inout
|
||||
variable angle
|
||||
|
||||
wave m_rotation_x = create_rotation_matrix_free()
|
||||
make /n=3/d/free w_temp_rotate_x
|
||||
@ -94,15 +184,25 @@ function rotate_x_wave(inout, angle)
|
||||
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[][ivec] = w_temp_rotate_x_result[p]
|
||||
endfor
|
||||
inout[0,2][ivec] = w_temp_rotate_x_result[p]
|
||||
endfor
|
||||
end
|
||||
|
||||
/// rotates a wave of 3-vectors about the y axis
|
||||
///
|
||||
/// this function rotates multiple vectors.
|
||||
///
|
||||
/// @param[in,out] inout wave with dimensions (M, N), M >= 3 (x, y, z), N >= 1.
|
||||
/// the result will be in same wave.
|
||||
/// only the first three rows of dimension 0 are used,
|
||||
/// extra rows are left unchanged.
|
||||
/// @param[in] angle rotation angle in degrees.
|
||||
///
|
||||
/// @return none
|
||||
///
|
||||
function rotate_y_wave(inout, angle)
|
||||
// rotates a wave of 3-vectors about the y axis
|
||||
wave inout // wave with dimensions (3, N), N >= 1, (x, y, z)
|
||||
// result will be in same wave
|
||||
variable angle // rotation angle in degrees
|
||||
wave inout
|
||||
variable angle
|
||||
|
||||
wave m_rotation_y = create_rotation_matrix_free()
|
||||
make /n=3/d/free w_temp_rotate_y
|
||||
@ -112,15 +212,25 @@ function rotate_y_wave(inout, angle)
|
||||
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[][ivec] = w_temp_rotate_y_result[p]
|
||||
inout[0,2][ivec] = w_temp_rotate_y_result[p]
|
||||
endfor
|
||||
end
|
||||
|
||||
/// rotates a wave of 3-vectors about the z axis
|
||||
///
|
||||
/// this function rotates multiple vectors.
|
||||
///
|
||||
/// @param[in,out] inout wave with dimensions (M, N), M >= 3 (x, y, z), N >= 1.
|
||||
/// the result will be in same wave.
|
||||
/// only the first three rows of dimension 0 are used,
|
||||
/// extra rows are left unchanged.
|
||||
/// @param[in] angle rotation angle in degrees.
|
||||
///
|
||||
/// @return none
|
||||
///
|
||||
function rotate_z_wave(inout, angle)
|
||||
// rotates a wave of 3-vectors about the z axis
|
||||
wave inout // wave with dimensions (3, N), N >= 1, (x, y, z)
|
||||
// result will be in same wave
|
||||
variable angle // rotation angle in degrees
|
||||
wave inout
|
||||
variable angle
|
||||
|
||||
wave m_rotation_z = create_rotation_matrix_free()
|
||||
make /n=3/d/free w_temp_rotate_z
|
||||
@ -130,6 +240,6 @@ function rotate_z_wave(inout, angle)
|
||||
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[][ivec] = w_temp_rotate_z_result[p]
|
||||
inout[0,2][ivec] = w_temp_rotate_z_result[p]
|
||||
endfor
|
||||
end
|
||||
|
Reference in New Issue
Block a user