Rotating a Mesh Grid by a Certain Angle
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で 3-D Scene Control についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!