Maths Python to Snap! block simple solution hopefully....
My knowledge of Python is limited. It all comes down to this last line on the Python script. In its simplest form just just add this variable (t) to that variable (inc) and add one to that (t) and then repeat in a sequential loop. But this last line of Python code has me stumped on my conversion, nothing works for me. t+=inc Any help appreciated on this challenge.
Thanks,
Pip
(The python script I am trying to convert is below)
from turtle import *
from math import sin, cos, pi
r=200
inc=2pi/100
t=0;n=1.5
for i in range(100):
x1=rsin(t); y1=rcos(t)
x2=rsin(t+n);y2=r*cos(t+n)
speed('fastest')
penup(); goto(x1,y1)
pendown();goto(x2,y2)
t+=inc
Hi bh, I did try that but it did not work for me. You can have a look here and see what you think. Your suggestions welcome, this is as far as I got... its nearly there but not quite as i hoped.
Good point. I had not noticed from my example Python script that my ‘cut-and-paste’ had removed all the asterisks ‘*’ on this forum. I am trying again here: I think it was the conversion from radians to degrees that originally made me confused. And you are right to point that out, thanks.
Hopefully this is correct with the asterisks:
from turtle import *
from math import sin, cos, pi
r=200
inc=2pi/100
t=0;n=1.5
for i in range(100):
x1=rsin(t); y1=rcos(t)
x2=rsin(t+n);y2=rcos(t+n)
speed('fastest')
penup(); goto(x1,y1)
pendown();goto(x2,y2)
# t+=inc
t+=inc # (increment angle for sin)
Try putting 3 backticks (```) before and after your code to format it as code. If you need to put asterisks in non-code, you can try prefixing each with a backslash (\).
pen down
for i = 0, steps
go to (radius * cos(i * 360 / steps)) (radius * sin(i * 360 / steps))
pen up
you can also use
pen down
for i = 0, steps
move dist
rotate by (360 / steps)
pen up
you can sorta change this if you want it to draw a dotted circle by using pen up and pen down in an if statement
you could also toggle the pen on and off