5
$\begingroup$

I thought of a project to get my feet wet with Mathematica and have completed it. If anyone finds time to look at the code and send some feedback I would appreciate it. If it's inappropriate to ask and you close this question, I will understand. It's important to me to learn how to write idiomatic code. This has been fun and I have already received lots of helpful suggestions here on SE. Here's a screen shot and a link to the notebook on dropbox.

megaminx

megademo.nb

$\endgroup$
1
  • 1
    $\begingroup$ I'm not really qualified to critique, but I think everything looks fairly idiomatic to me, and the code is fairly readable. Otherwise, I think it's a really neat project! It's like a Rubik's dodecahedron. I think finding a project that you think is neat is a great way to learn a language, and this exploits some of the graphics and dynamic features that might be much more difficult in other languages. $\endgroup$
    – MassDefect
    Commented May 7, 2020 at 3:58

1 Answer 1

4
$\begingroup$

I am not able to evaluate the OP's notebook, as it uses stuff that can't be parsed by version 11.2. Nevertheless, let me show a small demonstration of coloring a dodecahedron and adding lines to it, using the method from this answer, and the built-in PolyhedronData["Dodecahedron"]:

Graphics3D[{Directive[AbsoluteThickness[4], EdgeForm[AbsoluteThickness[4]]], 
            Transpose[{RandomSample[Lighter /@ {Yellow, Red, Green, Blue, Cyan, Gray,
                                                Magenta, Brown, Orange, Pink,
                                                Purple, White}], 
                       First[Normal[N @ PolyhedronData["Dodecahedron",
                                                       "GraphicsComplex"]]] /. 
                       Polygon[p_] :> 
                       With[{sides = Partition[p, 2, 1, 1], ut = (15 - Sqrt[5])/22},
                            {Polygon[p],
                             {Black, Line[Transpose[{{1 - ut, ut}.# & /@ sides, 
                                                     RotateLeft[{ut, 1 - ut}.# & /@
                                                                sides, 2]}]]
                            }}]}]}, Boxed -> False, Lighting -> "Neutral"]

colored dodecahedron

You might be able to modify it for your actual demonstration.

$\endgroup$
3
  • $\begingroup$ It works in the 12.1 Player. Do you know what I used to break 11.2? I would like my demo to work there also. I definitely want to study this. I thought there was a way to do this using the polyhedronData. Thanks again for another great answer! $\endgroup$
    – shirha
    Commented May 7, 2020 at 14:22
  • $\begingroup$ I don't doubt that it works in the current version. Nevertheless, I am providing an alternative that might still be useful, even in older versions. $\endgroup$ Commented May 7, 2020 at 14:35
  • $\begingroup$ @shirha My guess would be Polygon. It received some updates in V12, so you might be calling it in a way that earlier versions don't understand. $\endgroup$
    – MassDefect
    Commented May 7, 2020 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.