
Project the areas on the 3d model(car)
5 views (last 30 days)
Show older comments
Hello everyone,
I need help about some coding. I have the 3d model of a car and some areas around the car(actually at the side doors in the photo). I want that areas to be in the shape of 3d model. It is actually ok for the side door but imagine plotting it for the front, it would not be as same curvature as the front of the car has. How can I do it? Any ideas? It may be the projection of the areas on 3d model or something? If it even exist.
I use stlRead to read the 3d model and fill3 to plot the areas(as I have x y z coordinates).

4 Comments
darova
on 12 May 2020
Did you try to cut out the door only? something like inpolygon
clc,clear
cla
d1 = [0.4104 0.6557
0.2142 0.4443
0.2160 0.1739
0.7047 0.1807
0.6934 0.6489
0.4104 0.6557];
xd = d1(:,1);
yd = d1(:,2);
x = rand(100,1);
y = rand(100,1);
in = inpolygon(x,y,xd,yd);
plot(x,y,'.r')
hold on
plot(xd,yd)
plot(x(in),y(in),'or')
hold off
legend('all points','door','points inside')
You can draw the door manually using impoly
p = impoly;
p.getPosition
Accepted Answer
darova
on 15 May 2020
Here is a simple example. Should be heplfull
clc,clear
[x,y,z] = sphere(30);
ix = x > 0; % select half of the sphere only
% door coordinates
d1 = [0.4104 0.6557
0.2142 0.4443
0.2160 0.1739
0.7047 0.1807
0.6934 0.6489
0.4104 0.6557];
yd = d1(:,1)-0.5;
zd = d1(:,2);
gd = [2; length(yd); yd(:); zd(:)]; % door geometry
dl = decsg(gd); % decomposition of geometry
[p,e,t] = initmesh(dl); % create mesh
ydt = p(1,:)'; % Y coord of the door
zdt = p(2,:)'; % Z coord of the door
xdt = griddata(y(ix),z(ix),x(ix),ydt,zdt); % interpolate X coord
ff.vertices = [xdt ydt zdt];
ff.faces = t(1:3,:)';
ff.facecolor= 'yellow';
surf(x,y,z,'facecolor','none','edgecolor',[1 1 1]*0.8)
line(yd*0+1.2,yd,zd,'linew',2)
patch(ff)
axis vis3d equal

0 Comments
More Answers (0)
See Also
Categories
Find more on Surfaces, Volumes, and Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
