How do I use a transform matrix to get a new matrix?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2016-7-18
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 个评论
Star Strider
2016-7-18
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!