3 connected sticks, rotating

Post Reply
Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

3 connected sticks, rotating

Post by Henko »

Code: Select all

' 3 connected sticks, rotating
'
graphics ! graphics clear ! draw color 0,0,0 ! draw size 1
cx=screen_width()/2 ! cy=screen_height()/2
r1=cx/3 ! r2=cx/2 ! r3=cx/6
sp1=1 ! sp2=-1.1 ! sp3=1.0
f1=0 ! f2=1.5 ! f3=0.25
da=.01 ! shadow on
for sp3=1 to 2 step .1
  for a=0 to 64 step da
    x=cx+r1*cos(sp1*a+f1)+r2*cos(sp2*a+f2)+r3*cos(sp3*a+f3)
    y=cy+r1*sin(sp1*a+f1)+r2*sin(sp2*a+f2)+r3*sin(sp3*a+f3)
    if a=0 then draw to x,y else draw line to x,y
    next a
  pause 2 ! graphics clear
  next sp3
end

Henko
Posts: 814
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: 3 connected sticks, rotating

Post by Henko »

You might change the upper limit in the statement "FOR sp3=1 TO 2 STEP .1" from 2 into 3 for more interesting figures.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: 3 connected sticks, rotating

Post by Mr. Kibernetik »

My modification, with unlimited complexity and in colors:

Code: Select all

' 3 connected sticks, rotating
'
GRAPHICS ! GRAPHICS CLEAR ! DRAW COLOR 0,0,0 ! DRAW SIZE 1
cx=SCREEN_WIDTH()/2 ! cy=SCREEN_HEIGHT()/2
r1=cx/3 ! r2=cx/2 ! r3=cx/6
sp1=1 ! sp2=-1.1 ! sp3=1.0
f1=0 ! f2=1.5 ! f3=0.25
DA=.1 ! dsp=0.1 ! cm=2
SHADOW ON
REFRESH OFF
LOOP:
  GRAPHICS CLEAR
  FOR a=0 TO 64 STEP DA/sp3
    v1=sp1*a+f1 ! v2=sp2*a+f2 ! v3=sp3*a+f3
    x=cx+r1*COS(v1)+r2*COS(v2)+r3*COS(v3)
    y=cy+r1*SIN(v1)+r2*SIN(v2)+r3*SIN(v3)
    DRAW COLOR (SIN(v1*cm)+1)/2,(SIN(v2*cm)+1)/2,(SIN(v3*cm)+1)/2
    IF a=0 THEN DRAW TO x,y ELSE DRAW LINE TO x,y
    NEXT a
  REFRESH
  sp3+=dsp
  GOTO LOOP
END
image.png
image.png (2.41 MiB) Viewed 1512 times

Post Reply