Is it possible to do geometric transformations in LOGO?
In particular are horizontal reflections possible?
Starting with:
to ngon :n :s
repeat :n [ fd :s lt 360/:n]
end
ngon 5 50
I would like a command that would reflect across the line y=0 that would work something like
reflect ngon 5 50
and would produce the same result as
repeat 5 [ fd 50 rt 360/5]
Well, you can't change the behavior of
ltandrt. But there are some options.Option 1
You could write your own reversible versions of
ltandrt, and use these in your procedures where you previously used the regular versions:Option 2
You could wrap commands inside your procedures with a wrapper that executes the command after swapping
ltandrtas needed:Ideally there'd be a Logo command to get the body of an existing procedure, and then we could apply the wrapper to each line of the procedure dynamically, without needing to modify the procedure definition itself. But, I don't think such a command exists in Logo.
It's also worth noting that there are other commands that can change the heading or x-coordinate of the turtle. But we could imagine code similar to above that also updates
seth,xcor,setx,pos,setpos, etc.