View the step-by-step solution to:

G51PRG Semester Two Large Coursework One 2009/2010 Revision:10 This coursework is worth 15% of the total mark for this half of the module. When...

File is attached, I need solution in 3 days. Thanks
G51PRG Semester Two Large Coursework One 2009/2010 Revision: 1.10 This coursework is worth 15% of the total mark for this half of the module. When completed the worked solution should be submitted by 23:59:59 on Thursday 1st April, 2010. 1. Introduction This coursework is based around the Lindenmayer system (or L-System for short), which can be used to generate self-similar fractals. You can Fnd out more details about L-System in the accom- panying PD± . In this coursework, you will write a Java program that will read in a description of an L- System from a text Fle (supplied as a parameter on the command line) and draw the resulting frac- tal on the screen within a window. This will require you to use the Java Swing GUI library as well as do some simple string processing similar to the regular expression examples. The program can be split into two parts. ±irstly, the program will need to load in the data from the text Fle and use it to generate the description of the fractal. This is done by generating a string of characters based on the rules speciFed in the input Fle. The result of this is a string of the form: FX+YF++-FX-YF++-FX+YF+--FX-YF++-FX+YF++-FX-YF+--FX+YF+--FX-YF+ The second half of the program will take that string and use it draw the fractal in the window. This is done by processing the string character-by-character, and doing a speciFc operation based on each character. These ‘operators’ behave in the same manner as Turtle Graphics where some characters will move the ‘turtle’ forward and draw a line or rotate the turtle by a certain amount. It probably makes sense to generate the second half of the system (the display) Frst since it is slightly easier. Then once you have this working you can develop the generator and use it to drive the display. The following sections will describe how each section of the program should operate. Your submission should consist of the following: Your source code : that is the implementation of the L-System display and generator A short report (no more than 1000 words) explaining your program, and how it | works. In addition, you should outline the why you think the tests are sufFcient to test | your code. This should be submitted as a PD± Fle, the school provides access to | Adobe Distiller from the school UNIX systems, and the machines in B52 have the full | Adobe Acrobat suite installed under Windows. You should submit your coursework as a ZIP Fle using the cw submit command found on the school’s UNIX machines. ±ull details on how to use the cw system can be found at http://support.cs.nott.ac.uk/coursework/cwstud/ . † I’m very grateful to my PhD student, James Ollis, for writing the supporting document. http://en.wikipedia.org/wiki/Turtle_graphics
Background image of page 1
-2- 2. Implementation When fnished, your program should be able to be called like this: java LSystem <filename> <iterations> where <filename> is the name oF the fle that contains the description oF the L-System, and iterations is the number oF times to process the input string in order to generate the string that is actually used to draw the Fractal. Other than that, how you structure your program is up to you. You can use as many or as Few objects as you decide although you should justify your reasons in your report. 2.1. Displaying the Fractal This is the simpler part oF program, and so probably the best place to start. To display the Fractal on screen you will need to open a window (size 640 by 480 pixels) on screen containing a custom JComponent object. Your JComponent object will be responsible For drawing the Fractal in the window. To do this, we will use the notion oF ‘Turtle Graphics’ to draw things. This method is based around the idea oF a ‘turtle’ which is given instructions to move and as it moves it draws a line. The turtle can be told to move Forward or to turn to the leFt or the right by a specifc angle. IF the turtle turns then any Further movement happens along this axis. How you implement this is up to you. You could either investigate the Java Graphics2D object’s methods a bit more, or you may decide to calculate the angles involved yourselF (using Math.sin and Math.cos — but remember these work in radians rather than degrees). The initial start position and direction oF the Turtle is up to you, but you should aim to position it so the Fractals ft as nicely as possible in the window * . The same applies to how Far the turtle moves with each step. The actual drawing is done by considering the string generated by the L-System chacracter by character. Certain characters in the string will be interpreted as actions to make the turtle move, while other characters will be ignored. The characters with meaning are listed in the table below: Character Meaning A , B , F , G IF any oF these characters are encountered in the string, then the turtle should move Forward (in the current direction) by a fxed amount. (The amount the turtle moves is up to you, but see the comment above.) - This rotates the turtle to the leFt by a certain amount. The amount to turn is specifed on the frst line oF the fle describing the L-System (in degrees). + This rotates the turtle to the right by a certain amount. The amount to turn is specifed on the frst line oF the fle describing the L-System (in degrees). [ Save the current graphics state. That is the cur- rent position and direction oF the turtle. Multiple states can be saved and the are restored in a Last In, ±irst out Fashion. Advanced Feature only. ] Restore the graphics state saved previously with a ] . Advanced Feature only. * Do this in general, you should not be optimizing the position For each L-System.
Background image of page 2
Show entire document

This question was asked on Mar 29, 2010.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors and customizable flashcards—available anywhere, anytime.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access or to earn money with our Marketplace.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
  • -

    Flashcards

    Browse existing sets or create your own using our digital flashcard system. A simple yet effective studying tool to help you earn the grade that you want!

    Browse Flashcards