Spirograph, genereting curves,how?

#1

raw_ideas.dyn (7.3 KB)
2019-04-15_22h01_07

Hello Dynos,

I love this page ver much, i did some Vpython stuff:

I would like to create curves like a “Mauer rose”

Is there anaything like “turtle” in dynamo ? I can`t import any pen.
I ve seen i can use via designScript points, curves and they are driven by math.

In this Code, what have to be adapted to designScript:

import turtle \There is no turtle library, what can use instead?
from math import cos,sin
from time import sleep

window = turtle.Screen() \replaced by backgroundview in Dynamo
window.bgcolor("#FFFFFF")

myPen = turtle.Turtle()
myPen.hideturtle()
myPen.tracer(0)
myPen.speed(0)
myPen.pensize(3)
myPen.color("#AA00AA")

myPen.penup()

A = 100
B = 100
a = 3
b = 4
delta = 3.14/2
t=0

for i in range(0,1000): \that should work also in dynamo

  • t+=0.01*
  • #Apply Lissajous Parametric Equations*
  • x = A * sin(a*t + delta) *
  • y = B * sin(bt)
**myPen.goto(x,y)**

** myPen.pendown()**
** myPen.getscreen().update()**

sleep(0.5) \there is no sleep in Python - is it like “break”? The for loop should work

Maybe someone has some info about that, I just found a spiral example, but nothing more

KR

Andreas

1 Like
#2

an idea maybe


Zach Kron, post 27

#3

Why stop at only one?

2 Likes
#4

@Draxl_Andreas Created this Hypotrochoid using equations from here


Hypotrochoid.dyn (8.7 KB)

//Hypotrochoid
R = 5;
r = 3;
d = 5;
a = 0..n..1;
x = (R-r)*Math.Cos(a)+d*Math.Cos(((R-r)/r)*a);
y = (R-r)*Math.Sin(a)-d*Math.Sin(((R-r)/r)*a);
p1 = Point.ByCoordinates(x,y);

//Graphics for animation
p2 = (Point.Origin().Translate(Vector.XAxis(),R-r))
.Rotate(Point.Origin(),Vector.ZAxis(),a);
l1 = Line.ByStartPointEndPoint(p1,p2);
c1 = Circle.ByCenterPointRadius(Point.Origin(),R);
c2 = Circle.ByCenterPointRadius(p2,r);
[p1,c1,List.LastItem(l1),List.LastItem(c2)];
6 Likes