An Icosahedron - The Hard Way ------------------------------------------- The usual way to draw an icosahedron on a computer is to get the vertex coordinates from the Internet and also data about which vertices make up the edges and faces of the icosahedron. This project draws an icosahedron the hard way! It generates the vertices, edges and faces rather than inputting values for them. - The project generates the 12 vertices of the icosahedron. (An icosahedron has 12 vertices, 30 edges and 20 faces). The project generates 12 random points on a sphere, then tries to spread them equally around the sphere to become the vertices of the icosahedron. - The project generates the edges of the icosahedron by connecting the vertices that are closest together - The project generates the faces of the icosahedron. The project tests whether the vertices at both ends of an edge can be connected to a third common vertex along other edges. Each set of 3 vertices that are fully connected by edges form a triangular face of the icosahedron. Finally the project colours the faces and rotates the generated icosahedron. * It is not easy to spread points equally around a sphere. When the points are poorly spread by the algorithm I use, the project fails to produce an icosahedron. A regular icosahedron is one of the 5 Platonic Solids.
*** 3D Tutorial Studio now Open *** https://scratch.mit.edu/studios/5040029/ * Click "Green Flag" again if you do not get an icosahedron (as my algorithm for spreading out randomly generated vertices on a sphere may not always work - when the vertices "stick".) * Challenges * 1. EASY. Change one number inside the project to make it produce a Tetrahedron or Octahedron rather than an Icosahedron. 2. VERY HARD! Adapt the code to generate a cube or dodecahedron. The faces will be squares and pentagons, not triangles. The algorithm to spread points will need improving!! Huge thanks to @TheLogFather for his "Faster Triangle Filler" https://scratch.mit.edu/projects/24828481/ Theory to rotate a 3D object: https://en.wikipedia.org/wiki/Rotation_matrix Programming Notes: - the Internet will have better algorithms for spreading points on a sphere. I made up the algorithm in this project. - To spread points evenly on a sphere I thought it would be best to move each point away from the 3 closest neighbouring points but 2 closest neighbouring points seemed to work better more often. - The algorithm for spreading points may work a little better by moving points an angle greater than 1 degree initially but it looks better on the screen seeing the random points just spread a degree at a time.