필터 지우기
필터 지우기

Convert 3D polygon into homogeneous matrix

조회 수: 1 (최근 30일)
João Viveiros
João Viveiros 2012년 10월 13일
Hi. I have defined a 3D polygon creating a vertice and a face matrix to use the function Patch. Now i would like to know: how do i transform my 3D polygon in an homogeneous matrix.
Any clues ?
Thanks for the help.
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 10월 13일
What would the homogenous matrix consist of? For example are you looking to render it into a matrix? If so what value do you want at each location, taking into account that the polygon would in general be colored ?
João Viveiros
João Viveiros 2012년 10월 13일
편집: Walter Roberson 2012년 10월 13일
I need it homogeneous in order to aply geométric transformatrions to my polygon. I have this at the moment:
clc;clear all;close all;
vert=[2,0,0;2,1,0;1,1,0;1,0,0;1,0,1;2,0,1;2,1,1;1,1,1;1,2,1;0,2,1;0,1,1;
0,1,0;1,2,0;0,2,0;0,0,0;1,1,2;0,1,2;0,0,2;1,0,2;0,0,1;];
faces=[1,2,3,4;2,3,8,7;1,4,5,6;5,6,7,8;1,2,7,6;
3,8,9,13;3,12,14,13;9,13,14,10;11,12,14,10;8,9,10,11;
19,18,17,16;20,11,17,18;16,8,11,17;5,8,16,19;18,19,5,20;
20,11,12,15;5,20,15,4;3,4,15,12;];
P=patch('Faces',faces,'Vertices',vert,'FaceColor','r');
axis equal;
axis([-6 6 -6 6 -6 6])
xlabel('x');ylabel('y');zlabel('z');
hold on;grid on;
view(140,40);
'I need that P to be the homogeneous matrix so i can apply the geométric transformation to it by doing B=translation(3,0,0)*P (For example)
B is the new polygon transformed.
thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 10월 13일
The matrix "vert" in your code is your homogenous matrix for your purposes described in your comment.
  댓글 수: 1
João Viveiros
João Viveiros 2012년 10월 13일
Thanks. I homegenised my "vert" then, did a transformation to that matrix then i just re-patched.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Matt J
Matt J 2012년 10월 13일
Couldn't you just transform all of the vertices and recreate the patch? E.g.,
vert_translated=bsxfun(@plus, vert, [3,0,0]);
P=patch('Faces',faces,'Vertices',vert_translated,'FaceColor','r');
Note that invertible linear/affine transformations don't change the faces.

Matt J
Matt J 2012년 10월 13일
Instead of using PATCH, you could also consider using these 2 FEX files,
So first, this willl let you obtain your polyhedron as a set of inequalities A*x<=b
[A,b]=lcon2vert(vert);
Now you can transform the polyhedron as you like by appropriately transforming A and b. In the case of your translation, this would be
Anew=A;
bnew=b-A*[3;0;0];
Finally, you can plot using the plotregion() tool
plotregion(-Anew,-bnew);

카테고리

Help CenterFile Exchange에서 Elementary Polygons에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by