How do I use a transform matrix to get a new matrix?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Grant Sandy
am 18 Jul. 2016
Kommentiert: Grant Sandy
am 1 Aug. 2016
If I generate a 3D cylinder using the cylinder function
[x,y,z]=cylinder(1,60);
I can rotate the surface object with handle-graphics
(makehgtform(..); % which displays in the surf() just fine.
I know that the tc.Matrix will supply a 4x4 transformation matrix which looks correct, but the dimensions of x,y,and z are 2x61. The x and y coordinates are two identical rows (of circles) and the z has one row for the bottom of the cylinder and one row for the top. Here is the problem: How do I use the generated 4x4 transform matrix to create a new matrix that has been transformed (rotated and translated) with the 6 rows of x,y,z?
R = makehgtform('xrotate',xRotation,...
'yrotate',yRotation,...
'zrotate',zRotation);
S = makehgtform('translate',...
[xTranslation, yTranslation, zTranslation]);
tc.Matrix = S*R;
I need the actual transformed vectors for analysis - not just the surf plot. I should be able to multiply
tc.Matrix * [x; y; z]
to obtain the new matrix but the multiple rows in x,y,z are problematic.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 18 Jul. 2016
This uses the rotate function, not the ‘makehgtform’ functions, but it should demonstrate how to get the rotated and transformed data:
[x,y,z]=cylinder(1,60);
figure(1)
hcyl = surf(x,y,x); % Plot Cylinder
rotate(hcyl, [1 1 0], 25); % Rotate Cyulinder
hcylrot = get(hcyl); % Handle
xrot = hcylrot.XData; % Get Rotated Data
4 Kommentare
Star Strider
am 18 Jul. 2016
My pleasure!
It would help to see the relevant parts of your code. That way, I can experiment with it and probably provide a specific solution.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!