import mathutils, math
from mathutils import Vector
from turtle import *
from polygon import *

orient = mathutils.Quaternion((1,0,0,0)) #identity quaternion
orient = mathutils.Quaternion((0, 1, 0), math.radians(-90))
pos = Vector([0, 0, 0])
turtle = PTurtle(pos, orient, 0)
stack = []
mesh = Mesh([Vector([0,0,0])], [])

rot_esq_45 = mathutils.Quaternion((0, 0, 1), math.radians(45.0))
rot_dir_45 = mathutils.Quaternion((0, 0, 1), math.radians(-45.0))

print(rot_esq_45)

#vec_instr = [Df(1), Push(), Rot(rot_esq_45), Df(1), Rot(rot_dir_45), Df(1), Rot(rot_esq_45), Df(1), Pop(), Rot(rot_dir_45), Df(1), Rot(rot_esq_45), Df(1), Rot(rot_dir_45), Df(1)]

vec_instr = [Df(1),Push(), Rot(rot_dir_45), Df(1), Pop(), Rot(rot_esq_45), Df(1), Rot(rot_dir_45), Df(1), Rot(rot_esq_45), Df(1)]
Instruction.exec_all(turtle, stack, mesh, vec_instr)

print(mesh)

mesh.add_to_scene("mesh hello turtle", "obj hello turtle")
bpy.ops.wm.save_mainfile()
