How do I create a solid shape that has a smaller area on the bottom surface than the top surface?
3 views (last 30 days)
Show older comments
My code as of now is:
[x y] = meshgrid(-1:0.1:1); % Generate x and y data
z = zeros(size(x, 1)); % Generate z data
surf(x, y, z) % Plot the surface
%finding S value
xmin=min(min(x));
xmax=max(max(x));
ymin=min(min(y));
ymax=max(max(y));
zmin=min(min(z));
zmax=max(max(z));
SX=xmax-xmin;
SY=ymax-ymin;
SZ=2*(zmax-zmin);
S= largest value between SX, SY, and SZ
S=2;
figure(2)
surf2solid(x,y,x,S,5);
I want my final 3D shape to be tapered such that the area of the bottom surface is smaller than the top surface. I'm trying to get the X plane (on the lowest Z axis) to be smaller than the top surface.
2 Comments
John D'Errico
on 6 Jun 2018
Edited: John D'Errico
on 6 Jun 2018
What is surf2solid? MATLAB does not provide that tool. I'll guess this:
https://www.mathworks.com/matlabcentral/fileexchange/42876-surf2solid-make-a-solid-volume-from-a-surface-for-3d-printing
Anyway, what specific shape are you trying to create? A conic frustrum perhaps?
Answers (1)
John D'Errico
on 6 Jun 2018
Hmm. But not hard in any case. Best if the top and bottom polggons are the same length.
Suppose we create two polygons. If they have the same number of nodes, that is best, since then it is just a really simple mapping.
P1x = [0 3 3 0 0];
P1y = [0 0 3 3 0];
np = numel(P1x);
So a square for the base, of side length 3.
The top is a rectangle. 3 units wide on one edge, 1 unit wide on the other.
P2x = [0 3 3 0 0];
P2y = [1 1 2 2 1];
Height? 5 units.
zminmax = [0 5];
Well, that part was easy. Really though, you should follow rule number 1.
Rule number 1: ALWAYS plot EVERYTHING.
Rule number 2: See rule 1.
Rule number 3: Do you really honestly, seriously need to ask what rule number 3 is?
plot3(P1x,P1y,repmat(zminmax(1),1,np),'ro-')
hold on
plot3(P2x,P2y,repmat(zminmax(2),1,np),'bs-')
In fact, we can probably use similar calls to fill in the top and bottom faces of the frustrum, just using fill3.
First though, the sides.
t = linspace(0,1,11)';
X = t*P1x + (1-t)*P2x;
Y = t*P1y + (1-t)*P2y;
Z = t*repmat(zminmax(1),1,np) + (1-t)*repmat(zminmax(2),1,np);
surf(X,Y,Z)
hold on
fill3(P2x,P2y,repmat(zminmax(2),1,np),'r')
fill3(P1x,P1y,repmat(zminmax(1),1,np),'b')
So a right, trapezoidal frustrum, or something like that for a name.
1 Comment
See Also
Categories
Find more on Surface and Mesh Plots 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!