Rotating a meshgrid in 3D

5 Ansichten (letzte 30 Tage)
Zubair Ghani
Zubair Ghani am 4 Mär. 2021
Bearbeitet: Walter Roberson am 5 Mär. 2021
Ive got a meshgrid in 2d that i've been rotating so far. I want toe expand the mesh to 3d, and am having some trouble rotating it. This is how i've been doing it for 2D:
xLin = linspace(-10*scale/4,10*scale/4,200);
yLin = linspace(-10*scale/4,10*scale/4,200);
[x,y] = meshgrid(xLin,yLin); % create mesh
angle1 = -1*atan2(k1(1,2),k1(1,1));
XY1 = [x(:) y(:)];
R1=[cos(angle1) -sin(angle1); sin(angle1) cos(angle1)];
rotXY1=XY1*R1';
Xr1 = reshape(rotXY1(:,1), size(x,1), []);
Yr1 = reshape(rotXY1(:,2), size(y,1), []);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Mär. 2021
Bearbeitet: Walter Roberson am 5 Mär. 2021
The 3d process is much the same, except that you build xyz columns and multiply by a 3x3 array.
It can be easier to use makeghtform to build an appropriate 4x4 matrix. To use the 4x4 matrix, pad the xyz with a column of ones before doing the multiplication. Using the 4x4 permits easier rotation around an arbitrary center.
t=makehgtform(appropriate stuff)
xyz1 = xyz; xyz1(:, 4)=1;
newxyz = (t*xyz1')';

Weitere Antworten (0)

Kategorien

Mehr zu Bounding Regions finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by