make utm rotated grid with rotation vector and origin point in matlab

main.m
% Define the rotation angle and origin point
rotation_angle = 30; % in degrees
origin_point = [0, 0]; % origin point coordinates

% Define the grid size
[x, y] = meshgrid(-5:0.5:5, -5:0.5:5);

% Create the rotation matrix
R = [cosd(rotation_angle), -sind(rotation_angle); sind(rotation_angle), cosd(rotation_angle)];

% Transform the grid points with the rotation matrix and origin point
x_rot = R(1,1)*(x-origin_point(1)) + R(1,2)*(y-origin_point(2)) + origin_point(1);
y_rot = R(2,1)*(x-origin_point(1)) + R(2,2)*(y-origin_point(2)) + origin_point(2);

% Plot the rotated grid
figure;
plot(x_rot, y_rot, 'b.');
xlabel('x');
ylabel('y');
title('Rotated Grid with Rotation Vector in MATLAB');
693 chars
21 lines

related categories

gistlibby LogSnag