Plot a tilted looking polygon

2 views (last 30 days)
KRUNAL
KRUNAL on 22 Oct 2014
Answered: Ced on 22 Oct 2014
I have the following data that creates 3-d plot
x_min = 200; x_max = 500;
rand_x = x_min + (x_max - x_min )*rand(60,1);
y_min = -500; y_max = 950;
rand_y = y_min + (y_max - y_min )*rand(60,1);
z_min = -50; z_max = 50;
rand_z = (z_max - z_min )*rand(60,1);
plot3(rand_x,rand_y,rand_z,'x')
When I rotate it to look from the 2-d view it looks something like this :
What I want is, using the data(min n max of each axis can be changed) and using the same view i.e 2-d view of 3-d data, I want this to look a little tilted. Can anyone tell me how it can be done?

Answers (1)

Ced
Ced on 22 Oct 2014
Hi
You could simply multiply your points with a rotation matrix, e.g.
phi = pi/6;
R = [ cos(phi) sin(phi) 0 ; -sin(phi) cos(phi) 0 ; 0 0 1 ]; % R' turns in other direction
rand_new = R*[ rand_x' ; rand_y'; rand_z' ];
and plot them again. This changes the points (but makes the view look tilted as requested). Alternatively, if you only want to change the viewing angle, but keep the points at the same coordinates, you may need to play around with "view".

Community Treasure Hunt

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

Start Hunting!