![]() ![]() % lengthDecrement = number amount triangle shrinks each iteration % angleIncrement = number amount the triangle rotates each iteration % Draw a fractal triangle, with the following inputs: Take a look, and let me know if you have any questions!įunction fractalTriangle(r,angleIncrement,lengthDecrement,transparency) The inputs for fractalTriangle are described in the code below. We should have something that looks like this: So our draw subfunction will calculate the three points of the current triangle, based on the current length and angle parameters, and draw the triangle on top of the existing triangles. We want to rotate the triangle with each iteration, and also shrink it slightly. Then we simply draw lines between them using the plot command. Since we know that the three points of an equilateral triangle are separated by 120 degrees, we can simply rotate our first point to get our second and third points. It shows us the structure of the program we want to write, but will not run because the details haven't been filled in.įunction mainFunction (totalNumberOfIterations)įunction drawingFunction(remainingIterations)įor this example, we again harness the power of rotation! We want to draw a triangle centered around the origin. Note that the 'code' you see here is not really code at all. ![]() Thus, with a simple call to mainFunction you can draw an entire fractal structure! The only difference is that it calls itself with one less iteration. ![]() Then, importantly, drawingFunction calls itself. drawingFunction does the job of drawing your recursive structure, and takes as an input the number of recursions you want. Let's call it drawingFunction and color it blue in the example program below. In mainFunction, you call a second function- a sub-function. You begin with a function that will compute any global variables and compute and any non-iterative components of the drawing. The basic structure for each of these programs is very similar, so let's go over that first. Be warned: the greater the recursive depth, the longer the code will take to execute! You most likely won't have time in this class to code up your own recursive drawing, but you're encouraged to choose one of the patterns below and try changing a few parameters. Let's examine some of these deceptively simple-looking images. Perhaps the simplest fractals are created by the process of recursively drawing a particular pattern. On the title bar of your custom stencil, click Save to save the changes to the custom stencil with the new master shape.You can only get so far into mathematical art without mentioning fractals! As a review, a fractal is an image for which the same structre is evident at any level of resolution. To rename your new master shape, right-click the shape, click Rename Master, and then type a name for the new master shape. On the drawing page, select your custom shape and drag it into the new stencil in the Shapes window. In the Shapes window, click More Shapes, and then click New Stencil (US) or New Stencil (Metric). Save a custom shape as a new master shape Select the shape, click the vertex that you want to move, and then drag the vertex to a new position. ![]() Select the shape, point to where you want to add the vertex, hold down the CTRL key, and then click. Select the shape, click the vertex that you want to delete, and then press DELETE. On the Home tab, in the Tools group, open the Drawing Tools list and click the Pencil tool. You can edit most shapes by adding, deleting, and reshaping vertices in the shape. To stop drawing, on the Home tab, in the Tools group, click the Pointer tool. The shape becomes opaque, which indicates that it is a closed shape. To close the shape, drag the endpoint of the last segment that you create over the vertex at the beginning of the first segment. Segments are deleted in the reverse order in which they were drawn. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |