Paper stars are a big thing in my family at christmas, so I thought a virtual one would be cool.
Below is an image of a regular dodecahedron (from https://en.wikipedia.org/wiki/Dodecahedron, attributed to the author mentioned there.)
The process of stellation (wikipedia) when applied to a polyhedron involves extending the faces until they cross other faces. Thus starting with the regular dodecahedron, we obtain the following shapes:
Small Stellated Dodecahedron, Great Dodecahedron and Great Stellated Dodecahedron
Image from http://jwilson.coe.uga.edu/emat6680fa07/thrash/asn1/stellations.html
These are the three possible Stellations of the dodecahedron (Wolfram). They form a natural progression from the dodecahedron, to the small stellated dodecahedron, great dodecahedron and great stellated dodecahedron, as we extend the faces further and further out.
Your program or function should display or output to an image file one of the following polyhedra: Regular dodecahedron, Small stellated dodecahedron, Great dodecahedron or Great Stellated Dodecahedron.
The colour scheme should be as the second image above. Each of the six pairs of opposite faces shall be one of the six colours Red, Yellow, Green, Cyan, Blue, and Magenta. You may use default colours with these names in your language or its documentation, or use the colours FF0000, FFFF00, 00FF00, 00FFFF, 0000FF, and FF00FF (you may tone these down by reducing the intensity to a minimum of 75% if desired, for example by reducing the F's to C's.)
Note that we define a "face" as being all areas in the same plane. Thus in the images above the front face is yellow (and the parallel back face would also be yellow.)
Background should be black, grey, or white. Edges may be omitted, but should be black if drawn.
The displayed polyhedron must be between 500 and 1000 pixels in width (width is defined as the maximum distance between any two displayed vertices.)
The displayed polyhedron must be in perspective projection (viewpoint at least 5 widths away from the polyhedron), or orthographic projection (effectively a perspective projection with the viewpoint at infinity).
The polyhedron must be displayable from any angle. (It is not acceptable to pick the easiest possible angle and making a hardcoded 2D shape.) The angle can be specified by the user in either of the following ways:
Input of three angles corresponding to three rotations, from stdin, or as function or commandline parameters. These can be either Euler angles (where the first and last rotations are about the same axis) or Tait-Bryan angles (where there is one rotation each about the x, y and z axis) https://en.wikipedia.org/wiki/Euler_angles (simply put, anything goes so long as each rotation is about the x, y, or z axis and consecutive rotations are about perpendicular axes.)
Facility for the user to rotate the polyhedron in steps of not more than 10 degrees about the x and y axes and refresh the display, any arbitrary number of times (assuming z axis perpendicular to the screen).
The polyhedron must be solid, not wireframe.
No builtins for drawing polyhedra are allowed (I'm looking at you, Mathematica!)
This is codegolf. Shortest code in bytes wins.
Multiply your score by 0.5 if you do not use builtins for 3D drawing.
Multiply your score by 0.7 if you can display all three of the stellations of the dodecahedron, selectable by the user by an integer 1-3 entered from stdin, or by function or commandline parameter.
If you go for both bonuses your score will be multiplied by 0.5*0.7=0.35
Useful info (sources as below)
The dodecahedron has 20 vertices. 8 of them form the vertices of a cube with the following cartesian (x,y,z) coordinates:
(±1, ±1, ±1)
The remaining 12 are as follows (phi is the golden ratio)
(0, ± 1 / φ , ±φ)
(± 1 / φ , ±φ, 0)
(±φ, 0, ± 1 / φ )
The convex hull of the small stellated dodecahedron and great dodecahedron is obviously a regular dodecahedron. The outer vertices describe an icosahedron.
According to Wikipedia an icosahedron's 12 vertices can be described in a similar manner as cyclic permutations of (0, ±1, ±φ). The outer vertices of the small stellated dodecaheron and great dodechahedron (on the same scale as the dodecahedron above) form a larger icosahedron, where the coordinates of the vertices are cyclic permutations of (0, ±φ^2, ±φ).
The angles between faces for the dodecahedron and icosahedron are 2 arctan(phi) and arccos(-(√5)/3) respectively.
For tips on rotating, see https://en.wikipedia.org/wiki/Rotation_matrix
EDIT: By mistake I have allowed the regular dodecahedron, and can't retract it now. The x0.7 bonus for drawing all three of the stellated polyhedra remains. On New Year's Day I will issue a bounty of 100 for the answer that can display the most of the four polyhedra, with shortest code as the tie break.
dodecahedron) are disallowed. Some languages have facilities for building 3D models with commands like
triangle[[a,b,c],[p,q,r],[x,y,z]]. These languages generally have builtins for rotating and displaying the model, automatically taking care of not displaying hidden faces, etc. Solutions such as these are allowed but will not attract the bonus. The purpose of the bonus is to allow languages that do not have these facilities to be competitive, and also to attract more interesting solutions. \$\endgroup\$
Polyhedrondatais disallowed as it is clearly a builtin for drawing polyhedra. If your answer does not use builtins for drawing polyhedra, and complies with the other rules, then it is acceptable. Your point seems to be that given the fact that you have to colour the faces correctly,
Polyhedrondatawouldn't save you much anyway, so it may in practice be a somewhat arbitrary restriction. I agree to an extent, but It's fairer to all if I avoid changing rules after posting. \$\endgroup\$