In the last post, we looked at L-Systems and the basic principles of an L-System. This time we will take a quick look at how to use that in computer graphics.
An L-System can based on a string of characters, as seen in the previous post. Now, consider the following statement:
An L-System can based on a string of characters, as seen in the previous post. Now, consider the following statement:
Each letter in this string represents an action.
Lets say that the system consists of three letters, D,R and L. Each of these letters represent an action.
D: Draw a line 1 unit long
R: Turn 90 degrees right. Do nothing else
L: Turn 90 degrees left. Do nothing else
So, the combination DRD would mean "Draw a line, turn right, and then draw another line in the new direction."
DRDRDRD would mean Draw a line, turn right, draw a line, turn right, draw a line, turn right and draw a final line. This would result in a cube.
Now, let's say we use rules to transform a string of these commands.
Example:
Starting string: DRD
Rules: D = D
R = DRDLDRD
L = DLDRDLD
As a small excerscise, draw the shapes DRD and it's "child" DDRDLDRDD.
As you see, small corners are added to each corner. For each generation, more corners are getting "cut out".
This is a simple start on how to use L-Systems for drawing. There are more advanced examples, and we will get back to those in a later post.
Lets say that the system consists of three letters, D,R and L. Each of these letters represent an action.
D: Draw a line 1 unit long
R: Turn 90 degrees right. Do nothing else
L: Turn 90 degrees left. Do nothing else
So, the combination DRD would mean "Draw a line, turn right, and then draw another line in the new direction."
DRDRDRD would mean Draw a line, turn right, draw a line, turn right, draw a line, turn right and draw a final line. This would result in a cube.
Now, let's say we use rules to transform a string of these commands.
Example:
Starting string: DRD
Rules: D = D
R = DRDLDRD
L = DLDRDLD
As a small excerscise, draw the shapes DRD and it's "child" DDRDLDRDD.
As you see, small corners are added to each corner. For each generation, more corners are getting "cut out".
This is a simple start on how to use L-Systems for drawing. There are more advanced examples, and we will get back to those in a later post.
Powered by ScribeFire.