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 = round([cos(z),sin(z);(-sin(z)),cos(z)] .* 10000) ./ 10000; %test angle = 90; expectedrotationmatrix = [0 1;-1 0]; angle = angle*(pi/180); testrotationmatrix = round([cos(angle),sin(angle);(-sin(angle)),cos(angle)] .* 10000) ./10000 if (abs(abs(expectedrotationmatrix .- testrotationmatrix)) < 1e-10) disp("Test #1 Passed") else disp("Test #1 Failed") endif endfunction