## Copyright (C) 2023 gabri ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {} {@var{retval} =} create2DRotationMatrix (@var{input1}, @var{input2}) ## ## @seealso{} ## @end deftypefn ## Author: gabri ## Created: 2023-02-03 function myrotationmatrix = create2DRotationMatrix (z) %%%%%%%%%%%%%%%%% %the function create2DRotationMatrix takes an agle in degrees as a argument, %and returns the corresponding 2D rotation matrix % % % INPUT : rotation angle in degrees % % OUTPUT : rotation matrix in size 2 by 2 % %Created by: Gabriel LUCAS %Date Creation: 03/02/2023 11:05:22 % %Last Modified: 03/02/2023 11:06:51 %%%%%%%%%%%%%%%%%% z = z*(pi/180); myrotationmatrix = [cos(z),sin(z);(-sin(z)),cos(z)] %test angle = 90; expectedrotationmatrix = [0 1;-1 0]; angle = angle*(pi/180); testrotationmatrix = [cos(angle),sin(angle);(-sin(angle)),cos(angle)] if (abs(abs(expectedrotationmatrix .- testrotationmatrix)) < 1e-10) disp("Test #1 Passed") else disp("Test #1 Failed") endif endfunction