Created
March 23, 2015 10:06
-
-
Save OrganicIrradiation/f8bde9e0520d35defbc4 to your computer and use it in GitHub Desktop.
3D “Potato” Generation using Sinusoidal Pertubations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nRecurse = 0; | |
FV = sphere_tri('ico',nRecurse,[],0); | |
lighting phong; | |
shading interp; | |
figure; | |
patch('vertices', FV.vertices,'faces', FV.faces, 'facecolor', [0.5 0.5 0.5], 'edgecolor', [.2 .2 .2]); | |
axis square; | |
axis off; | |
camlight infinite; | |
camproj('orthographic'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
figure; | |
amplitude = 0.15; | |
for angle = 0:pi/4:3/4*pi | |
for frequency = 1:3:10 | |
newShape = FV; | |
% Rotate around x-axis | |
a=cos(angle) * frequency; | |
b=sin(angle) * frequency; | |
newShape.vertices(:,1) = newShape.vertices(:,1) + sin(a*newShape.vertices(:,2) + b*newShape.vertices(:,3)) * amplitude; | |
subplot(4,4,(angle+pi/4)/(pi/4)+((frequency+2)-3)/3*4) | |
lighting phong; | |
shading interp; | |
patch('vertices', newShape.vertices, 'faces', newShape.faces, 'facecolor', [0.5 0.5 0.5], 'edgealpha', 0); | |
axis equal; | |
axis off; | |
camlight infinite; | |
camproj('orthographic'); | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
figure; | |
amplitude = 0.15; | |
for angle = 0:pi/4:3/4*pi | |
for frequency = 1:3:10 | |
newShape = FV; | |
% Rotate around x-axis | |
a=cos(angle) * frequency; | |
b=sin(angle) * frequency; | |
newShape.vertices(:,2) = newShape.vertices(:,2) + sin(a*newShape.vertices(:,1) + b*newShape.vertices(:,3)) * amplitude; | |
subplot(4,4,(angle+pi/4)/(pi/4)+((frequency+2)-3)/3*4) | |
lighting phong; | |
shading interp; | |
patch('vertices', newShape.vertices, 'faces', newShape.faces, 'facecolor', [0.5 0.5 0.5], 'edgealpha', 0); | |
axis equal; | |
axis off; | |
camlight infinite; | |
camproj('orthographic'); | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
figure; | |
amplitude = 0.15; | |
for angle = 0:pi/4:3/4*pi | |
for frequency = 1:3:10 | |
newShape = FV; | |
% Rotate around x-axis | |
a=cos(angle) * frequency; | |
b=sin(angle) * frequency; | |
newShape.vertices(:,3) = newShape.vertices(:,3) + sin(a*newShape.vertices(:,1) + b*newShape.vertices(:,2)) * amplitude; | |
subplot(4,4,(angle+pi/4)/(pi/4)+((frequency+2)-3)/3*4) | |
lighting phong; | |
shading interp; | |
patch('vertices',newShape.vertices,'faces',newShape.faces,... | |
'facecolor',[0.5 0.5 0.5],'edgealpha',0); | |
axis equal; | |
axis off; | |
camlight infinite; | |
camproj('orthographic'); | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% X-axis: | |
newShape.vertices(:,1) = newShape.vertices(:,1) + sin(a*newShape.vertices(:,2) + b*newShape.vertices(:,3)) * amplitude; | |
% Y-axis: | |
newShape.vertices(:,2) = newShape.vertices(:,2) + sin(a*newShape.vertices(:,1) + b*newShape.vertices(:,3)) * amplitude; | |
% Z-axis: | |
newShape.vertices(:,3) = newShape.vertices(:,3) + sin(a*newShape.vertices(:,1) + b*newShape.vertices(:,2)) * amplitude; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment