Rotating a Mesh Grid by a Certain Angle

조회 수: 1 (최근 30일)
Greg B.
Greg B. 2015년 9월 4일
Hi all,
I have a set of grid nodes that I'm trying to rotate 30 degrees clockwise, using the 2D rotation matrix for xy coordinates.
Following the rotation, I get rotated grid nodes, which seem rotated when I plot them; however, the nodes are not evenly spaced.
My starting nodes are latitudes and longitudes, each are [14:0.5:14], with longitude flipped using flipud. So following the use of meshgrid, each grid node is spaced 0.50 degrees apart.
I wish to rotate 30 degrees, using the rotation in the script; however my grid nodes are not evenly spaced (i.e. 0.34, 0.43, and 0.44). The spacing isn't constant.
My question is: How to I rotate an entire set of grid nodes by a certain angle, so that the grid node spacing is constant (0.50 degrees)? In this code, I also wish to move the grid nodes down the y-axis by 0.50 degrees, which is why there is a +0.50 after b_rot. While this code works, it does not output rotated grid nodes with equal spacing. Thank you for your help, and my code is below:
%%%%%Read in the Latitudes and the Longitudes (opposite) %%%%%
lat = flipud(load('Grid'));
lon = load('Grid');
Creates the grid of Lat and Lon Coordinates %%%%%
[LAT LON] = meshgrid(lat,lon);
a=LAT';
b=LON';
angle = 30;
a_rot = a*cosd(angle) - b*sind(angle);
b_rot = (a*sind(angle) + b*cosd(angle))+0.50;
%%%%%Plot the Grid Nodes %%%%%
figure(1)
plot(a_rot, b_rot, 'o','MarkerEdgeColor','k','MarkerFaceColor','k');
axis([-15 15 -15 15]);

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactions, Camera Views, and Lighting에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by