Azzera filtri
Azzera filtri

How to rotate 3D matrix?

10 visualizzazioni (ultimi 30 giorni)
Florence
Florence il 11 Mag 2021
Commentato: Florence il 11 Mag 2021
I have 3 matrices for surf commands: X, Y, Z. I transformed the matrix so that the surface rotates -45 degrees around the OY axis. But now my current code can make it rotate -45 degrees, but it deviates A (one edge of the surface)form a certain distance. Can someone help me improve my code to make the surface rotate with A as the axis?thank you very much!.
My code is below:
a=-45;
R=[cosd(a) sind(a);-sind(a) cosd(a)];
V=R*[X(:),Z(:)]';
X1=reshape(V(1,:),size(X));
Z1=reshape(V(2,:),size(Z));
surf(X1,Y,Z1);

Risposta accettata

J. Alex Lee
J. Alex Lee il 11 Mag 2021
it looks like your segment A is parallel to the axis OA (trivial in y-direction), in which case it should be easy to first translate such that A and OA coincide...then do your rotation, then untranslate to put A back where it belongs.
depending on what you need, this might be useful (disclaimer i have not used hgtransform before):
  1 Commento
Florence
Florence il 11 Mag 2021
First of all thank you for your reply, I will think about it seriously. Thank you very much

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Object Containers in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by