added function for creating rotation matrix
This commit is contained in:
parent
d5bac7abee
commit
b94011196b
|
|
@ -1,3 +1,5 @@
|
||||||
# reasoningaboutspace
|
# reasoningaboutspace
|
||||||
|
|
||||||
we are doing this to try the tests functions about rotation matrix
|
we are doing this to try the tests functions about rotation matrix
|
||||||
|
|
||||||
|
create2DRotationMatrix.m takes the rotation angle z, and returns the corresponding rotation matrix
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
## 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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
## -*- texinfo -*-
|
||||||
|
## @deftypefn {} {@var{retval} =} create2DRotationMatrix (@var{input1}, @var{input2})
|
||||||
|
##
|
||||||
|
## @seealso{}
|
||||||
|
## @end deftypefn
|
||||||
|
|
||||||
|
## Author: gabri <gabri@DESKTOP-AA36H6D>
|
||||||
|
## 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
|
||||||
Loading…
Reference in New Issue