[SOLVED] logo turtle implementation

How can implement correctly the turtle move and rotation for blender?

this is my attempt:


import bpy
import math
# rota longitudinalmente:
#rotTurtleFromFront
# rota transversalmente:
#rotTurtleFromRight
class tortuga:
    def __init__(self):
        self.oldX = 0
        self.oldY = 1
        self.oldZ = 0
        self.newX = 0.0
        self.newY = 0.0
        self.newZ = 0.0
    # rota alrededor del eje de la normal:
    def rotTurtleFromTop(self, angulo):
        # si A es menos a 0 entonces se mueve en direccion de las agujar de un reloj
        # si A es mayor que 0 entonces se mueve en direccion contraria a las agujas de un reloj
        # convertir de radians a grados:
        # A = (( angulo * math.pi )/180.0)
        A = math.radians(angulo) # <-- lo mismo pero con python
        # cos (90) es 0 y sin (90) es 1
        self.newX = self.oldX * math.cos(A) - self.oldY * math.sin(A)
        self.newY = self.oldX * math.sin(A) + self.oldY * math.cos(A)
        # update olds:
        self.oldX = self.newX
        self.oldY = self.newY
        self.oldZ = self.newZ
        print(self.oldX,self.oldY,self.oldZ)
        return [self.oldX,self.oldY,self.oldZ]


t = tortuga()
bpy.context.selected_objects[0].rotation_euler = t.rotTurtleFromTop(90)

References: http://slideplayer.com/slide/7675933/ https://www.google.es/url?sa=t&source=web&rct=j&url=https://www.clear.rice.edu/comp360/lectures/TurtleProg.pdf&ved=0ahUKEwiN7LqjtLbNAhVIExoKHfJ9C_sQFggcMAA&usg=AFQjCNHEfnXEL4FWDNzs-ecyRTP49Cwkhg

Solution: