How can I use faces, vertices and normals from an STL-file to create a hyperplane arrangement?

180 views
Skip to first unread message

Stingar

unread,
Feb 6, 2017, 3:59:50 AM2/6/17
to YALMIP

I have exported a 3D model from Sketch-up as an STL-file (basically triangles) consisting of faces, vertices and normals, and now I am looking for a way to describe this model using hyperplanes.
My most promising solution so far is to use the Polyhedron function that comes with the MPT toolbox, which apparently can switch between a hyperplane representation, and a "vertices and rays" representation". I thought I could use this, but when I try to do this on a single triangle, it gets "dragged out" using the Polyhedron function. When I try to plot the full model, as I have done using Matlabs function "patch" below, it will not display anything at all. I might have misunderstood what a ray is in this context, but I thought it would just be a triangle normal.

clear all
load data
% Start at 1350 as the data seems to contain a lot of unnecessary triangles
figure
patch
('Faces',faces(1350:end,:),'Vertices',vertices,'FaceColor','r','EdgeColor','k','FaceAlpha',0.7);

% Plot the last "triangle" using mpt
P
= Polyhedron('V', vertices(faces(end,:),:), 'R', normals(end,:));
plot
(P)

% Plot the last triangle using patch
figure
hold on
patch
('Faces',faces(end,:),'Vertices',vertices,'FaceColor','r','EdgeColor','k','FaceAlpha',0.7);
start
= [sum(vertices(faces(end,:),1)) sum(vertices(faces(end,:),2)) sum(vertices(faces(end,:),3))]/3;
line
([start(1) start(1)+normals(end,1)],[start(2) start(2)+normals(end,2)], [start(3) start(3)+normals(end,3)])

Have I misunderstood something?
Also, is there a simpel way in Yalmip to go from faces, vertices and normal, over to a hyperplane arrangement?
data.mat

Johan Löfberg

unread,
Feb 6, 2017, 7:13:40 AM2/6/17
to YALMIP
This is really not YALMIP related.

YALMIP per se does not have any direct notion on polytopes etc. The only thing you can do is to extract data 

x= sdpvar(n,1);
getbasematrix
(A*x<=b]

will return [b -A]
Reply all
Reply to author
Forward
0 new messages