Rotating 3D data

3 views (last 30 days)
태신 김
태신 김 on 15 Nov 2021
Commented: 태신 김 on 17 Nov 2021
I made X, Y coordinates and a triangle with zeros and ones on this plane.
I want to rotate this triangle 45 degrees. I tried rotz(), but I don't have idea to do this.
Thanks in advance.
clc; clear all; close all;
x = linspace(-10,10,49);
y = linspace(-10,10,44);
[X,Y] = meshgrid(x,-y);
Z = zeros(44,49);
Z = importdata('triangle_rotate.txt');
imagesc(Z)

Accepted Answer

Chunru
Chunru on 15 Nov 2021
clc; clear all; close all;
x = linspace(-10,10,49);
y = linspace(-10,10,44);
[X,Y] = meshgrid(x,-y);
Z = zeros(44,49);
Z = importdata('triangle_rotate.txt');
subplot(121); imagesc(Z); axis equal
Z1 = imrotate(Z, 45);
subplot(122); imagesc(Z1); axis equal
  6 Comments
Matt J
Matt J on 16 Nov 2021
You can use the crop option to keep the array the matrix the same size, but there is no guarantee the rotated object will fit inside the original borders:
Z = importdata('triangle_rotate.txt');
Z=imrotate(Z,45,'bicubic', 'crop');
태신 김
태신 김 on 17 Nov 2021
Thank you for your helpful answers.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!