updated the creation of the rotation matrix, and corrected a mistake
This commit is contained in:
parent
b94011196b
commit
8c3d7ffe05
|
|
@ -1,27 +1,3 @@
|
||||||
## 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)
|
function myrotationmatrix = create2DRotationMatrix (z)
|
||||||
%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%
|
||||||
%the function create2DRotationMatrix takes an agle in degrees as a argument,
|
%the function create2DRotationMatrix takes an agle in degrees as a argument,
|
||||||
|
|
@ -38,13 +14,13 @@ function myrotationmatrix = create2DRotationMatrix (z)
|
||||||
%Last Modified: 03/02/2023 11:06:51
|
%Last Modified: 03/02/2023 11:06:51
|
||||||
%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%
|
||||||
z = z*(pi/180);
|
z = z*(pi/180);
|
||||||
myrotationmatrix = [cos(z),sin(z);(-sin(z)),cos(z)]
|
myrotationmatrix = round([cos(z),sin(z);(-sin(z)),cos(z)] .* 10000) ./ 10000;
|
||||||
|
|
||||||
%test
|
%test
|
||||||
angle = 90;
|
angle = 90;
|
||||||
expectedrotationmatrix = [0 1;-1 0];
|
expectedrotationmatrix = [0 1;-1 0];
|
||||||
angle = angle*(pi/180);
|
angle = angle*(pi/180);
|
||||||
testrotationmatrix = [cos(angle),sin(angle);(-sin(angle)),cos(angle)]
|
testrotationmatrix = round([cos(angle),sin(angle);(-sin(angle)),cos(angle)] .* 10000) ./10000
|
||||||
if (abs(abs(expectedrotationmatrix .- testrotationmatrix)) < 1e-10)
|
if (abs(abs(expectedrotationmatrix .- testrotationmatrix)) < 1e-10)
|
||||||
disp("Test #1 Passed")
|
disp("Test #1 Passed")
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue