MATLAB Answers

Convert 3D polygon into homogeneous matrix

Asked by João Viveiros on 13 Oct 2012

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.


Walter Roberson
on 13 Oct 2012

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 on 13 Oct 2012

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;
axis equal;
axis([-6 6 -6 6 -6 6])
hold on;grid on;

'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.




No products are associated with this question.

3 Answers

Answer by Walter Roberson
on 13 Oct 2012
 Accepted answer

The matrix "vert" in your code is your homogenous matrix for your purposes described in your comment.

  1 Comment

João Viveiros on 13 Oct 2012

Thanks. I homegenised my "vert" then, did a transformation to that matrix then i just re-patched.

Matt J
Answer by Matt J
on 13 Oct 2012

Couldn't you just transform all of the vertices and recreate the patch? E.g.,

 vert_translated=bsxfun(@plus, vert, [3,0,0]);

Note that invertible linear/affine transformations don't change the faces.

  1 Comment

João Viveiros on 13 Oct 2012

I did that ;) thanks. its working

Matt J
Answer by Matt J
on 13 Oct 2012

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


Now you can transform the polyhedron as you like by appropriately transforming A and b. In the case of your translation, this would be


Finally, you can plot using the plotregion() tool



Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today