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)
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
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?
Rebekah Abrams
Rebekah Abrams on 6 Jun 2018
I found surf2solid at this link but its the same thing as your link.The actual shape I want to use tapering for is fairly complex so for simplicity, the shape I am making is generally rectangular. Ideally, I'd want to just taper the longer sides and leave the shorter sides as is.

Sign in to comment.

Answers (1)

John D'Errico
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
Rebekah Abrams
Rebekah Abrams on 7 Jun 2018
Edited: Rebekah Abrams on 7 Jun 2018
As of right now, my code goes through each point to taper the shape. The code is the following where SOLIDX2 is a 27x67 matrix:
SOLIDX2(1:4,1:16) = 0.8* SOLIDX2(1:4,1:16); SOLIDX2(24:27,1:16) = 0.85* SOLIDX2(24:27,1:16);
SOLIDX2(1:4,1:4) = 1.01*SOLIDX2(1:4,1:4); SOLIDX2(24:27,1:4) = 1.02*SOLIDX2(24:27,1:4);
SOLIDX2(1:4,5) = 1.01*SOLIDX2(1:4,5); SOLIDX2(24:27,5) = 1.03*SOLIDX2(24:27,5);
SOLIDX2(1:4,6) = 1.03*SOLIDX2(1:4,6); SOLIDX2(24:27,6) = 1.07*SOLIDX2(24:27,6);
SOLIDX2(1:4,7) = 1.06*SOLIDX2(1:4,7); SOLIDX2(24:27,7) = 1.08*SOLIDX2(24:27,7);
SOLIDX2(1:4,8) = 1.09*SOLIDX2(1:4,8); SOLIDX2(24:27,8) = 1.09*SOLIDX2(24:27,8);
SOLIDX2(1:4,9) = 1.11*SOLIDX2(1:4,9); SOLIDX2(24:27,9) = 1.10*SOLIDX2(24:27,9);
SOLIDX2(1:4,10) = 1.13*SOLIDX2(1:4,10); SOLIDX2(24:27,10) = 1.11*SOLIDX2(24:27,10);
SOLIDX2(1:4,11) = 1.15*SOLIDX2(1:4,11); SOLIDX2(24:27,11) = 1.12*SOLIDX2(24:27,11);
SOLIDX2(1:4,12) = 1.17*SOLIDX2(1:4,12); SOLIDX2(24:27,12) = 1.13*SOLIDX2(24:27,12);
SOLIDX2(1:4,13) = 1.19*SOLIDX2(1:4,13); SOLIDX2(24:27,13) = 1.14*SOLIDX2(24:27,13);
SOLIDX2(1:4,14) = 1.21*SOLIDX2(1:4,14); SOLIDX2(24:27,14) = 1.15*SOLIDX2(24:27,14);
SOLIDX2(1:4,15) = 1.23*SOLIDX2(1:4,15); SOLIDX2(24:27,15) = 1.16*SOLIDX2(24:27,15);
SOLIDX2(1:4,16) = 1.25*SOLIDX2(1:4,16); SOLIDX2(24:27,16) = 1.17*SOLIDX2(24:27,16);
SOLIDX2(22:26,4) = SOLIDX2(22:26,5); SOLIDY2(22:26,4) = SOLIDY2(22:26,5);
SOLIDX2(22:26,3) = SOLIDX2(22:26,5); SOLIDY2(22:26,3) = SOLIDY2(22:26,5);
SOLIDX2(22:26,2) = SOLIDX2(22:26,5); SOLIDY2(22:26,2) = SOLIDY2(22:26,5);
Its very repetetive. I've been trying to turn this into a function so I could repeat it. The function I have as of right now is:
function [ SOLIDpiece1 ] = MidTaper( SOLIDX2,j,k )
% This function should apply a tapered edge to the midfoot of the
% orthotic using just the original matrix (SOLIDX2)
z = zeros(1,16) ;
n=1.01;
for i = 1:16
SOLIDX2piece1=SOLIDX2(j:k,1:i);
if i == [1,1]
z(i) = n*SOLIDX2(i,i) ;
else
SOLIDpiece1(i) = (n+(.2*i))*SOLIDX2piece1 ;
end
end
end
However, I keep getting this error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in MidTaper (line 14)
SOLIDpiece1(i) = (n+(.2*i))*SOLIDX2piece1 ;
if you have any suggestions or how to tweak this, that would be incredible.

Sign in to comment.

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!