Python Forum
How to find axiom of this picture
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find axiom of this picture
#1
Photo 
Hey folks. I'm wondering if anyone can help me to find axioms of these pictures somehow
[Image: 0?ui=2&ik=96f9b9e177&attid=0.3&permmsgid..._k7rhizl01]
[Image: 0?ui=2&ik=96f9b9e177&attid=0.1&permmsgid..._k7rhizog2][Image: 0?ui=2&ik=96f9b9e177&attid=0.2&permmsgid..._k7rhizoo3]
Reply
#2
Define "axiom" in this context. Also, what have you tried, or looked up or anything? We aren't here to do the work for you.
Reply
#3
Hello, thank you for your reply.
sorry about that. I forgot to show what I've worked. So this is what I've worked :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import turtle
 
D = 90
L = 10
 
def iterate(axiom, num=0, initator='F'):
    """
    Compute turtle rule string by iterating on an axiom
    """
 
    def translate(current, axiom):
        """
        Translate all the "F" with the axiom for current string
        """
        result = ''
        consts = {'+', '-', '[', ']'}
        for c in current:
            if c in consts:
                result += c
                continue
            if c == 'F':
                result += axiom
        return result
 
    # Set initator
    result = initator
    for i in range(0, num):
        # For ever iteration, translate the rule string
        result = translate(result, axiom)
    return result
 
def draw(axiom, d=D, l=L):
    """
    Use turtle to draw the L-System
    """
    stack  = []                 # For tracking turtle positions
    screen = turtle.Screen()
    screen.bgcolor('black')
    screen.setup(width=1000,height=1000,startx = 500,starty=0)
    alex   = turtle.Turtle()
    alex.pencolor('yellow')
    alex.up()
    alex.left(90)  
    alex.setposition(0,-250)
    alex.down()
    alex.hideturtle()     
    alex.speed(1)              
             
     
 
    for i in range(len(axiom)):
        c = axiom[i]
 
        if c == 'F':
            alex.forward(l)
 
        if c == '-':
            alex.left(d)
 
        if c == '+':
            alex.right(d)
 
        if c == '[':
            stack.append((alex.heading(), alex.pos()))
             
 
        if c == ']':
            heading, position = stack.pop()
            alex.penup()
            alex.goto(position)
            alex.setheading(heading)
            alex.pendown()
 
if __name__ == '__main__':
        axiom = "FF-[-F+F+F]+[+F-F-F]"
        axiom = iterate(axiom, 5, "F")
        draw(axiom, 25, 13)
So using the FF-[-F+F+F]+[+F-F-F] as the axiom and using:

[python]
for i in range(len(axiom)):
c = axiom[i]

if c == 'F':
alex.forward(l)

if c == '-':
alex.left(d)

if c == '+':
alex.right(d)

if c == '[':
stack.append((alex.heading(), alex.pos()))


if c == ']':
heading, position = stack.pop()
alex.penup()
alex.goto(position)
alex.setheading(heading)
alex.pendown()
[\pyhton]
as the rule will produce this image
https://mail.google.com/mail/u/0?ui=2&ik..._k7szjeoz1

So now my lecturer told me to find the axiom of those pictures by applying the same rule.

Thanks you. Sorry for my bad english.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to modify and get the same picture vokoyo 1 2,827 Jul-07-2019, 11:37 AM
Last Post: dataman
  Why there is no any input of the picture? Tony 2 3,362 May-19-2018, 07:20 AM
Last Post: Tony

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020