
We have now looked over the user interface of our app and can see that all of the geometry creation for the snowflake must happen within the method. Second, the resultant geometry is plotted in the graphics window. First, the method CreateSnowFlake is called. There are two commands that are run when the button is pressed. Next, we can look at the settings for our button, as shown in the screenshot below. We limit the user to five iterations, as we use an algorithm that is not very efficient but is quite simple to implement. This source is similarly selected for the Data Display feature to display the number of iterations to take. The screenshot below shows the slider’s settings and the values, which are specified to be integers between 0 and 5. The slider feature within the user interface controls the value of the integer, Iterations. A single element in the array has a value of 0.5, which is used to find the centerpoint of each edge. There is also a 1D array of double-precision numbers, named Center. There are two Declarations within the app that define an integer value, named Iterations, which is zero by default but changed by the user.

The app has a single form with five features. There is also a Text Label (label 3) and a Data Display (label 4) that show the number of iterations that are taken, as well as a Graphics window (label 5) in which the resultant geometry is plotted. It has only two features with which the user can interact: a Slider (labeled 1 in the image below) that specifies the number of iterations to take to produce the snowflake, and a Button (label 2) to select, which creates and displays the resultant geometry. The app has a very simple user interface. Laying Out the App’s User Interface with the Application Builder This single triangle is equivalent to the zeroth iteration of the Koch snowflake, and we are now ready to use the Application Builder to create more complex snowflakes. Now that we defined the geometry part, we can call a single instance of the part within the Geometry branch. The part is rotated about the center of the bottom edge.

The input parameters for the geometry part are defined.Ī polygon primitive is used to define an equilateral triangle. The five parameters that are used to control the size, position, and orientation of an equilateral triangle. This part takes five inputs: the side length of an equilateral triangle the x– and y-locations of the midpoint of the base and the components of the normal vector, pointing from the midpoint of the base to the far vertex, as shown in the images below. We begin with a new file and create a 2D geometry part within the Global Definitions node.
KOCH SNOWFLAKE ACTIONSCRIPT VECTOR CODE HOW TO
Now that we know what algorithm to use, let’s look at how to create such a structure with the Application Builder and COMSOL Multiphysics. Building the Geometry of a Koch Snowflake

Licensed under CC BY-SA 3.0, via Wikimedia Commons. The first four iterations of a Koch snowflake. This procedure is illustrated in the figure below for the first four iterations of the snowflake. Repeat steps 2-4 for as many iterations as desired.Define the next iteration of the Koch snowflake to be the outside perimeter of the previous snowflake and all of the added triangles.At the centerpoint of every edge, add a protruding equilateral triangle that is 1/3 the side length of the length of the current edge.Find the centerpoint of every edge of the current snowflake.Start with an equilateral triangle, which is actually the zeroth iteration of a Koch snowflake.The Koch snowflake is a fractal that is notable due to its very simple iterative construction process: Today, we will look at how this shape can be built with the Application Builder in COMSOL Multiphysics.Īs we have already mentioned on the blog, fractals have some interesting engineering applications. However, there is one special kind of snowflake that can be simply described, known as the Koch snowflake. As I was staring out the window earlier, I started thinking about snowflakes and how their formation cannot be easily described mathematically. It has been a remarkably warm winter in Boston, but we finally got our first snowfall.
