5.0

5.0 | 1 rating Rate this file 12 Downloads (last 30 days) File Size: 2.06 KB File ID: #28213
image thumbnail

platonic_solid

by Kevin Moerman

 

15 Jul 2010

Creates the PATCH data, the vertices (V) and faces (F) for a desired platonic solid

| Watch this File

File Information
Description

function [V,F]=platonic_solid(n,r)

Creates the PATCH data, the vertices (V) and faces (F) for
a given platonic solid (according to "n" see below) with radius (r)

n=1 -> Tetrahedron
n=2 -> Cube
n=3 -> Octahedron
n=4 -> Icosahedron
n=5 -> Dodecahedron

%% Example

clear all; close all; clc;

r=1;
figure;fig=gcf; clf(fig); colordef (fig, 'white'); units=get(fig,'units'); set(fig,'units','normalized','outerposition',[0 0 1 1]); set(fig,'units',units); set(fig,'Color',[1 1 1]);
hold on;

[V,F]=platonic_solid(1,r);
subplot(2,3,1);
patch('Faces',F,'Vertices',V,'FaceColor','b','FaceAlpha',0.6,'EdgeColor','k','LineWidth',2); axis equal; grid on; hold on; view(3); axis off;

[V,F]=platonic_solid(2,r);
subplot(2,3,2);
patch('Faces',F,'Vertices',V,'FaceColor','b','FaceAlpha',0.6,'EdgeColor','k','LineWidth',2); axis equal; grid on; hold on; view(3); axis off;

[V,F]=platonic_solid(3,r);
subplot(2,3,3);
patch('Faces',F,'Vertices',V,'FaceColor','b','FaceAlpha',0.6,'EdgeColor','k','LineWidth',2); axis equal; grid on; hold on; view(3); axis off;

[V,F]=platonic_solid(4,r);
subplot(2,3,4);
patch('Faces',F,'Vertices',V,'FaceColor','b','FaceAlpha',0.6,'EdgeColor','k','LineWidth',2); axis equal; grid on; hold on; view(3); axis off;

[V,F]=platonic_solid(5,r);
subplot(2,3,5);
patch('Faces',F,'Vertices',V,'FaceColor','b','FaceAlpha',0.6,'EdgeColor','k','LineWidth',2); axis equal; grid on; hold on; view(3); axis off;

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
29 Nov 2011 John  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
platonic solid Kevin Moerman 15 Jul 2010 11:44:09
patch Kevin Moerman 15 Jul 2010 11:44:09
tetrahedron Kevin Moerman 15 Jul 2010 11:44:09
cube Kevin Moerman 15 Jul 2010 11:44:09
dodecahedron Kevin Moerman 15 Jul 2010 11:44:10
icosahedron Kevin Moerman 15 Jul 2010 11:44:10
octahedron Kevin Moerman 15 Jul 2010 11:44:10
cube Salman 01 Jul 2011 21:40:56
patch Brett Ables 28 Sep 2011 18:27:36

Contact us at files@mathworks.com