I need help with task 6 I have absolutely no idea about how

I need help with task 6. I have absolutely no idea about how to start.

koch.fdl looks like this

Fractal Description Language Many fractals can be generated from descriptions in the Fractal Description Language (.fdl). This language describes a start state of a fractal and a set of rules how to progress to larger depths. For example, to generate a Koch curve, we start with the initial (depth 0) state F signifying a forward move, i.e., a straight line. The rule for expanding to the next depth is given as a replacement rule. F->FLFRF LIF where L is a 60 degree turn to the left and R is a 120 degree turn to the right. That is, we replace a straight line by a straight line, a left-turn, a straight line, a sharp right-turn, a straight line, a left-turn, and a fourth and final straight line. Thus, the state for depth 1 is FL F R F L F. To get to depth 2, we have to apply the rule again to all positions of the state where it is possible, i.e., we have to replace each of the four F by FLFR F L F. The result Is F L F R F L F L F L F R F L F R F L F R F L F L F L F R F L F where the new sections are underlined to aid your understanding. To get to depth 3, we would have to replace each of the 16 Fs by the right side of the rule. For the sake of brevity, I leave this exercise to you. Let us take a look at the file koch.fdl available from the project section of the course home page. The first line give the start state, i.e., the state F for depth 0. The second line give the only rule needed for the Koch curve, i.e., start F rule F ->FLFRFLFto replace F by F LFRFL F. The third length 2 depth 5 cmd F fd cmd L lt 60 cmd R rt 120 line specifies the length of each segment, i.e each straight line will be 2 units long. The fourth line specifies that states should be ex panded to depth 5 before drawing the frac tal. Finally, the Lines 5 to 7 specify that F is a straight line, L is a 60 degree left-turn and R is a 120 degree right-turn.

Solution

By the way you did not mention wchich programming language to use:

However, every programming language follows the same logics, despite the difference in syntaxeses.

As you know the rule is to replace each left by right side For the task 6 we have to implement a method by that performes this action.

For your understanding:

A method takes an argument (Any value / type / arrays) and returns after calculations.

Here We need to implement sucha a method named apply. As given above...

apply(\"F\" , [\"F\",\"L\",\"F\",\"R\",\"F\",\"L\",\"F\"] , [\"F\",\"R\",\"F\",\"R\",\"F\"])

Here you can clearly understand that the method takes three values/arguments The first just a String \"F\", second and third String arrays ([] indicates array in programming ).

The method goes here:

Using java to write method:

// Before you use the method you must declare the method with their datatypes

// So the method returns String array Return type also mentioned as array type of string

public String[] apply(String leftLetter, String arrayRight[], String arrayStatus[])

{   

//Here creating a new String array with the size of 50

// This means the array now can hold 50 string in it

// You can change it depends on the requirements

String[] arrayGenerated=new String[50];

// Using a variable to store string into new array at right indexes serially

int index=0;

// For loop to check weather we have any \"F\" in the sequence or not

for(int i=0;i<arrayStatus.length;i++)

{

// While repeating if detects any element as \"F\" then replcing with right

if(arrayStatus[i].equals(leftLetter))

{

// Again loop for right side because it\'s not a single string

for(int j=0;j<arrayRight.length;j++)

{

// Here loading value from right side to the new arraygenerated to return

arrayGenerated[index]=arrayRight[j];

// After loading incrementing index by one this indicates to load next value at right spot

index++;

}

}

else

// If not Find \"F\" then no replace as it is

arrayGenerated[index]=arrayState[i];

}

}

I need help with task 6. I have absolutely no idea about how to start. koch.fdl looks like this Fractal Description Language Many fractals can be generated from
I need help with task 6. I have absolutely no idea about how to start. koch.fdl looks like this Fractal Description Language Many fractals can be generated from

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site