{"id":1361,"date":"2016-03-28T12:00:44","date_gmt":"2016-03-28T17:00:44","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=1361"},"modified":"2016-03-29T04:10:25","modified_gmt":"2016-03-29T09:10:25","slug":"piet-hein-super-ellipses-and-soma-cubes","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2016\/03\/28\/piet-hein-super-ellipses-and-soma-cubes\/","title":{"rendered":"Piet Hein, Super Ellipses and Soma Cubes"},"content":{"rendered":"<div class=\"content\"><h3>Contents<\/h3><div><ul><li><a href=\"#9c4ea03d-cd88-4432-9aa2-c20bafa0bc70\">Piet Hein (1905-1996)<\/a><\/li><li><a href=\"#35859175-e83a-4d9f-9528-3c42edfb1fbe\">Grooks<\/a><\/li><li><a href=\"#21e028eb-2c3f-4010-be49-18158f25e808\">Porcelain<\/a><\/li><li><a href=\"#8d0eda56-1383-447b-916f-1dfae4645e06\">Super Ellipses<\/a><\/li><li><a href=\"#4b5555b7-7e49-4343-974b-560de60d5919\">The p-norm<\/a><\/li><li><a href=\"#28beca99-d9b5-49b1-bf37-3a2cd1390e98\">Soma Cube<\/a><\/li><li><a href=\"#71eddd2b-472f-4b49-a18d-e10c01da018c\">Soma Cube demo<\/a><\/li><\/ul><\/div><h4>Piet Hein (1905-1996)<a name=\"9c4ea03d-cd88-4432-9aa2-c20bafa0bc70\"><\/a><\/h4><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/piet_hein.jpg\" alt=\"\"> <\/p><p>Let's quote the entry about Piet Hein in David Darling's <i>Enclopedia of Science<\/i>, <a href=\"http:\/\/www.daviddarling.info\/encyclopedia\/H\/Hein.html\">http:\/\/www.daviddarling.info\/encyclopedia\/H\/Hein.html<\/a><\/p><p>\r\n<!--introduction--><p style=\"margin-left:3ex;\">\r\nAn extraordinarily creative Danish mathematician, inventor, and poet\r\nwho often wrote under the Old Norse pseudonym \"Kumbel\" meaning\r\n\"tombstone.\" A direct descendant of the Dutch naval hero of the\r\n16th century who had the same name, Piet Hein was born in Copenhagen\r\nand studied at the Institute for Theoretical Physics of the University\r\nof Copenhagen (later the Niels Bohr Institute) and the Technical\r\nUniversity of Denmark.\r\n<\/p><!--\/introduction-->\r\n<\/p><p>\r\n<p style=\"margin-left:3ex;\">\r\n[Piet Hein] is famed for his many mathematical games, including Hex,\r\nTangloids,  Polytaire, TacTix, and the Soma Cube, his advocacy of the\r\nsuperellipse curve in applications as diverse as city planning and\r\nfurniture making,  and his thousands of short, aphoristic poems called\r\nGrooks.\r\n<\/p>\r\n<\/p><h4>Grooks<a name=\"35859175-e83a-4d9f-9528-3c42edfb1fbe\"><\/a><\/h4><p>This is one line from one of the Grooks.<\/p><pre>      \"Problems worthy\r\n      of attack\r\n      prove their worth\r\n      by hitting back!\"\r\n         -- Piet Hein<\/pre><h4>Porcelain<a name=\"21e028eb-2c3f-4010-be49-18158f25e808\"><\/a><\/h4><p>My wife and I purchased one of these Piet Hein pocelain baking dishes years ago during a visit to Denmark.  It's been a mainstay in our kitchen ever since. This photo is not from our kitchen, it's from a page at <a href=\"http:\/\/www.piethein.com\">http:\/\/www.piethein.com<\/a> featuring <a href=\"\"><\/a>.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/porcelain.jpg\" alt=\"\"> <\/p><h4>Super Ellipses<a name=\"8d0eda56-1383-447b-916f-1dfae4645e06\"><\/a><\/h4><p>Hein's design of the baking dish, as well as many other items, is based on what he called the <i>superellipse<\/i>, a curve that lies between old-fashioned ellipses and rectangles. The important parameter $p$ controls the roundness. Additional parameters $a$ and $b$ determine the aspect ratio. A superellipse with these parameters is the set of points $(x,y)$ satisfing<\/p><p>$$ |\\frac{x}{a}|^p + |\\frac{y}{b}|^p = 1 $$<\/p><p>If $a$ and $b$ are both equal to one, the equation is<\/p><p>$$ |x|^p + |y|^p = 1 $$<\/p><p>And if $p$ is equal to two it becomes<\/p><p>$$ x^2 + y^2= 1 $$<\/p><p>which defines a circle.<\/p><p>Here is the MATLAB definition.<\/p><pre class=\"codeinput\">   F = @(x,y) abs(x\/a).^p + abs(y\/b).^p - 1;\r\n<\/pre><p>Let's vary <tt>p<\/tt> between 0.1 and 10 and make an animated gif, pausing briefly as we pass through <tt>p = 1<\/tt> and <tt>p = 2<\/tt>.<\/p><pre class=\"codeinput\">   type <span class=\"string\">make_superellipse_movie<\/span>\r\n<\/pre><pre class=\"codeoutput\">\r\n    gif_frame('superellipse_movie.gif')\r\n    for p = [0.1 0.1 0.1:0.1:1 1 1 1:0.2:2 2 2 2:.5:10]\r\n       F = @(x,y) abs(x).^p + abs(y).^p - 1;\r\n       ezplot(F,[-1.2 1.2])\r\n       axis square\r\n       title(['|x|^p + |y|^p = 1, p = ',sprintf('%.1f',p)])\r\n       gif_frame\r\n    end\r\n<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/superellipse_movie.gif\" alt=\"\"> <\/p><p>All of Piet's designs have <tt>p = 2.5<\/tt>.<\/p><pre class=\"codeinput\">   p = 2.5;\r\n   a = 1.5;\r\n   F = @(x,y) abs(x\/a).^p + abs(y).^p - 1;\r\n   ezplot(F,[-1.8 1.8])\r\n   axis <span class=\"string\">equal<\/span>\r\n   title(sprintf(<span class=\"string\">'Superellipse, p = %.1f'<\/span>,p))\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/piet_hein_blog_01.png\" alt=\"\"> <p>Different scale factors on <tt>x<\/tt> and <tt>y<\/tt> make the shape rectangular and <tt>p<\/tt> greater than two makes it not exactly an ellipse.<\/p><h4>The p-norm<a name=\"4b5555b7-7e49-4343-974b-560de60d5919\"><\/a><\/h4><p>I could have said that the superellipse is the unit ball in two dimensions of the vector p-norm,<\/p><p>$$ ||v||_p = \\big( \\sum_i |v_i]^p \\big)^{1\/p} $$<\/p><p>In MATLAB this is <tt>norm(v,p)<\/tt>.  In other words the function <tt>F<\/tt> starring in the first animated gif could have been defined by<\/p><pre class=\"codeinput\">   F = @(x,y) norm([x,y],p) - 1;\r\n<\/pre><p>When <tt>p = 1<\/tt> the unit \"ball\" becomes the unit diamond. And for <tt>p &lt; 1<\/tt> the quantity <tt>norm(v,p)<\/tt> is no longer actually a norm.  It fails to satisfy the triangle inequality.<\/p><p>Homework: what is <tt>norm(v,p)<\/tt> for <i>negative<\/i> <tt>p<\/tt>, and when <tt>p = -Inf<\/tt>?<\/p><h4>Soma Cube<a name=\"28beca99-d9b5-49b1-bf37-3a2cd1390e98\"><\/a><\/h4><p>Use the Images option in Google to search for all of the different images of \"Soma Cube\" available on the Internet.  It's awesome.<\/p><p>Here is one of those images, available from <a href=\"http:\/\/mathcats.org\/ideabank\/geometrykits.html\">http:\/\/mathcats.org\/ideabank\/geometrykits.html<\/a>. This is all possible shapes with a reentrant corner that can be made out of three or four \"cubelets\".  There are a total of 27 of those cubelets.  The goal is to make a 3-by-3-by-3 larger cube.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/soma_cube.jpg\" alt=\"\"> <\/p><p>My father's hobby was woodworking.  He had a very nice shop. One year when I was a kid, he and I made 12 Soma Cube puzzle sets like this one to give to our family for Christmas.  My set is now over 65 years old, but I still have it in my office at home.<\/p><h4>Soma Cube demo<a name=\"71eddd2b-472f-4b49-a18d-e10c01da018c\"><\/a><\/h4><p>The following is the shortest code segment I've ever presented in over 2-1\/2 years of Cleve's Corner blog.  In the command window of your own copy of MATLAB you can enter.<\/p><pre class=\"language-matlab\">soma\r\n<\/pre><p>This launches an old demo written by Bill McKeeman. Click away, to your heart's content. In this animated gif, watch the solution number change . It's looping over only the first 12 out of the 240 possible puzzle solutions that McKeeman's algorithm finds.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/soma_movie.gif\" alt=\"\"> <\/p><p>McKeeman and I were buddies in grad school.  We spent too many hours perfecting our Some Cube skills.  In fact, I can still put the puzzle together behind my back.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_9095f8b1b6fe4f0c9bec4a8e9675441f() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='9095f8b1b6fe4f0c9bec4a8e9675441f ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 9095f8b1b6fe4f0c9bec4a8e9675441f';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2016 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_9095f8b1b6fe4f0c9bec4a8e9675441f()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2015b<br><\/p><\/div><!--\r\n9095f8b1b6fe4f0c9bec4a8e9675441f ##### SOURCE BEGIN #####\r\n%% Piet Hein, Super Ellipses and Soma Cubes\r\n\r\n%% Piet Hein (1905-1996)\r\n%\r\n% <<piet_hein.jpg>>\r\n\r\n%% \r\n% Let's quote the entry about Piet Hein in David Darling's\r\n% _Enclopedia of Science_,\r\n% <http:\/\/www.daviddarling.info\/encyclopedia\/H\/Hein.html>\r\n\r\n\r\n%%\r\n%\r\n% <html>\r\n% <p style=\"margin-left:3ex;\">\r\n% An extraordinarily creative Danish mathematician, inventor, and poet\r\n% who often wrote under the Old Norse pseudonym \"Kumbel\" meaning\r\n% \"tombstone.\" A direct descendant of the Dutch naval hero of the\r\n% 16th century who had the same name, Piet Hein was born in Copenhagen \r\n% and studied at the Institute for Theoretical Physics of the University \r\n% of Copenhagen (later the Niels Bohr Institute) and the Technical \r\n% University of Denmark.\r\n% <\/p>\r\n% <\/html>\r\n%\r\n% <html>\r\n% <p style=\"margin-left:3ex;\">\r\n% [Piet Hein] is famed for his many mathematical games, including Hex,\r\n% Tangloids,  Polytaire, TacTix, and the Soma Cube, his advocacy of the\r\n% superellipse curve in applications as diverse as city planning and\r\n% furniture making,  and his thousands of short, aphoristic poems called\r\n% Grooks. \r\n% <\/p>\r\n% <\/html>\r\n%\r\n\r\n%% Grooks\r\n% This is one line from one of the Grooks.\r\n%  \r\n%        \"Problems worthy \r\n%        of attack\r\n%        prove their worth\r\n%        by hitting back!\"\r\n%           REPLACE_WITH_DASH_DASH Piet Hein\r\n\r\n%% Porcelain\r\n% My wife and I purchased one of these Piet Hein pocelain baking dishes\r\n% years ago during a visit to Denmark.  It's been a mainstay in our\r\n% kitchen ever since.\r\n% This photo is not from our kitchen, it's from a page at \r\n% <http:\/\/www.piethein.com> featuring\r\n% <>.\r\n%\r\n% <<porcelain.jpg>>\r\n%\r\n\r\n%% Super Ellipses\r\n% Hein's design of the baking dish, as well as many other items, is\r\n% based on what he called the _superellipse_, a curve that lies between\r\n% old-fashioned ellipses and rectangles.\r\n% The important parameter $p$ controls the roundness.\r\n% Additional parameters $a$ and $b$ determine the aspect ratio.\r\n% A superellipse with these parameters is the set of points\r\n% $(x,y)$ satisfing\r\n%\r\n% $$ |\\frac{x}{a}|^p + |\\frac{y}{b}|^p = 1 $$\r\n%\r\n% If $a$ and $b$ are both equal to one, the equation is\r\n%\r\n% $$ |x|^p + |y|^p = 1 $$\r\n%\r\n% And if $p$ is equal to two it becomes\r\n%\r\n% $$ x^2 + y^2= 1 $$\r\n%\r\n% which defines a circle.\r\n%\r\n% Here is the MATLAB definition.\r\n\r\n   F = @(x,y) abs(x\/a).^p + abs(y\/b).^p - 1;\r\n   \r\n%%\r\n% Let's vary |p| between 0.1 and 10 and make an animated gif,\r\n% pausing briefly as we pass through |p = 1| and |p = 2|.\r\n\r\n   type make_superellipse_movie\r\n    \r\n%%\r\n% <<superellipse_movie.gif>>\r\n\r\n%%\r\n% All of Piet's designs have |p = 2.5|.\r\n\r\n   p = 2.5;\r\n   a = 1.5;\r\n   F = @(x,y) abs(x\/a).^p + abs(y).^p - 1;\r\n   ezplot(F,[-1.8 1.8])\r\n   axis equal\r\n   title(sprintf('Superellipse, p = %.1f',p))\r\n   \r\n%%\r\n% Different scale factors on |x| and |y| make the shape rectangular\r\n% and |p| greater than two makes it not exactly an ellipse.\r\n\r\n%% The p-norm\r\n% I could have said that the superellipse is the unit ball in two\r\n% dimensions of the vector p-norm,\r\n%\r\n% $$ ||v||_p = \\big( \\sum_i |v_i]^p \\big)^{1\/p} $$\r\n%\r\n% In MATLAB this is |norm(v,p)|.  In other words the function |F|\r\n% starring in the first animated gif could have been defined by\r\n\r\n   F = @(x,y) norm([x,y],p) - 1;\r\n   \r\n%%\r\n% When |p = 1| the unit \"ball\" becomes the unit diamond.\r\n% And for |p < 1| the quantity |norm(v,p)| is no longer actually\r\n% a norm.  It fails to satisfy the triangle inequality.\r\n\r\n%%\r\n% Homework: what is |norm(v,p)| for _negative_ |p|, and when |p = -Inf|?\r\n\r\n%% Soma Cube\r\n% Use the Images option in Google to search for all of the different\r\n% images of \"Soma Cube\" available on the Internet.  It's awesome.\r\n\r\n%%\r\n% Here is one of those images, available from\r\n% <http:\/\/mathcats.org\/ideabank\/geometrykits.html>.\r\n% This is all possible shapes with a reentrant corner that can be\r\n% made out of three or four \"cubelets\".  There are a total of 27\r\n% of those cubelets.  The goal is to make a 3-by-3-by-3 larger cube.\r\n%\r\n% <<soma_cube.jpg>>\r\n\r\n%%\r\n% My father's hobby was woodworking.  He had a very nice shop.\r\n% One year when I was a kid, he and I made 12 Soma Cube puzzle sets\r\n% like this one to give to our family for Christmas.  My set is now\r\n% over 65 years old, but I still have it in my office at home.\r\n\r\n%% Soma Cube demo\r\n% The following is the shortest code segment I've ever presented in\r\n% over 2-1\/2 years of Cleve's Corner blog.  In the command window\r\n% of your own copy of MATLAB you can enter.\r\n%\r\n%   soma\r\n%\r\n\r\n%%\r\n% This launches an old demo written by Bill McKeeman.\r\n% Click away, to your heart's content.\r\n% In this animated gif, watch the solution number change .\r\n% It's looping over only the first 12 out of the 240 possible puzzle\r\n% solutions that McKeeman's algorithm finds.\r\n%\r\n% <<soma_movie.gif>>\r\n%\r\n\r\n%%\r\n% McKeeman and I were buddies in grad school.  We spent too many hours\r\n% perfecting our Some Cube skills.  In fact, I can still put the puzzle\r\n% together behind my back.\r\n\r\n\r\n\r\n##### SOURCE END ##### 9095f8b1b6fe4f0c9bec4a8e9675441f\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/feature_image\/piet_hein.jpg\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p style=\"margin-left:3ex;\">\r\nAn extraordinarily creative Danish mathematician, inventor, and poet\r\nwho often wrote under the Old Norse pseudonym \"Kumbel\" meaning\r\n\"tombstone.\" A direct descendant of the Dutch naval hero of the\r\n16th century who had the same name, Piet Hein was born in Copenhagen\r\nand studied at the Institute for Theoretical Physics of the University\r\nof Copenhagen (later the Niels Bohr Institute) and the Technical\r\nUniversity of Denmark.\r\n... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2016\/03\/28\/piet-hein-super-ellipses-and-soma-cubes\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":1363,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,23,4,8],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/1361"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=1361"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/1361\/revisions"}],"predecessor-version":[{"id":1380,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/1361\/revisions\/1380"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/1363"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=1361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=1361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=1361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}