3
$\begingroup$

I asked on the Math Stack Exchange here how I could find the area of a "generalized Koch snowflake". An $n$th generalized Koch snowflake, in my case, is formed almost the same as the Koch snowflake - but instead of starting with an equilateral triangle, the start is a regular $n$-gon and the next iteration is formed by placing a regular $n$-gon with a side length $1/3$ of the previous side length on each side of the previous iteration.

How can I find or at least approximate this area given $n$ and the starting side length? I think maybe using polygons is the way to go, but I am new to Mathematica and don't really know how to use them.

$\endgroup$
  • 1
    $\begingroup$ It might be possible to do this with GeometricScene, although I haven't put in the time to create it. Perhaps something useful to be gleaned at this answer (and the question in general for other methods of generating scenes) $\endgroup$ – Carl Lange May 12 at 19:51
  • $\begingroup$ You may also find KochCurve interesting, and there are many Demonstrations relating to Koch curves and snowflakes. $\endgroup$ – Carl Lange May 12 at 19:59
4
$\begingroup$

enter image description here


Here is a start. KochCurve transforms a unit vector {{0,0},{0,1}}. This unit vector can be geometrically transformed via FindGeometricTransform into any polygon side. So given a side of a polygon you 1st FindGeometricTransform of unit vector into it and then transform with it KochCurve. The following function can transform any line into KochCurve:

ClearAll[lineKoch];
lineKoch[n_][vec_]:=
Last[FindGeometricTransform[vec,{{0,0},{1,0}}]][
ReflectionTransform[{0,1}][First[KochCurve[n]]]]

And the following function using lineKoch will transform any set of polygon vertex points into a n-Koch MeshRegion:

ClearAll[polyKoch];
polyKoch[n_][pt_]:=
MeshRegion[#,Polygon[Range[Length[#]]]]&@
Flatten[lineKoch[n]/@Partition[pt,2,1,1],1]

You need MeshRegion because Area or RegionMeasure can get the approximate area. You can see it at work, by applying it to some random point-sets:

Labeled[#,Area[#]]&[polyKoch[4][#]]&/@
Table[(#[[Last[FindShortestTour[#]]]]&@
RandomReal[1,{RandomInteger[{3,7}],2}]),10]

which will produce the image at the top of this post. You can also design an interactive app to change your polygons:

Manipulate[
Column[{Area[#],Show[#,PlotRange->2]}]&@polyKoch[n][pt],
{{n,2},Range[2,5]},
{{pt,CirclePoints[3]},Locator,LocatorAutoCreate->True}]

enter image description here

UPDATE: other Koch shapes

To change Koch substitution shape use proper syntax of KochCurve function:

shape={{1,0},{1,90°},{1,-90°},{2,-90°},{1,90°},{1,90°},{1,-90°}};

lineKoch[n_][vec_]:=
Last[FindGeometricTransform[vec,{{0,0},{1,0}}]][
ReflectionTransform[{0,1}][First[KochCurve[n,shape]]]]

polyKoch[n_][pt_]:=
MeshRegion[#,Polygon[Range[Length[#]]]]&@
Flatten[lineKoch[n]/@Partition[pt,2,1,1],1]

Labeled[#,Area[#]]&[polyKoch[4][#]]&/@
Table[(#[[Last[FindShortestTour[#]]]]&@
RandomReal[1,{RandomInteger[{3,7}],2}]),10]

enter image description here

$\endgroup$
  • $\begingroup$ How can I change it from adding triangles to adding other polygons? $\endgroup$ – automaticallyGenerated May 15 at 23:22
  • $\begingroup$ @automaticallyGenerated I do not understand your question. In this post you see demos with arbitrary polygons. What do you mean? $\endgroup$ – Vitaliy Kaurov May 15 at 23:24
  • $\begingroup$ I see that it starts off with arbitrary polygons, but how can I change it so that it adds a square/regular pentagon, hexagon, etc in the middle of each side instead of an equilateral triangle? Sorry if this is a basic question - I'm new to Mathematica. $\endgroup$ – automaticallyGenerated May 15 at 23:26
  • $\begingroup$ @automaticallyGenerated I added example at the end. Please look through examples in docs on KochCurve --- there is syntax of this function to make arbitrary-shape replacements . $\endgroup$ – Vitaliy Kaurov May 15 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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