[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:LOGO-L>Knots



The trefoil knot is equivalent to the overhand knot.  One of the projections
of the trefoil onto a plane is a hypotrochoid, which is the locus of
a point, P, on the radius vector of a circle (radius rs),which rolls inside
another circle (radius rl).
The parametric equations are:
 X = dr*cos(theta)+h*cos ((dr/rs)*theta)
 Y = dr*cos(theta)-h*sin ((dr/rs)*theta)
Where h = distance of P from the centre of the circle(rs)
      dr = rl-rs
If z =  sin(rl*theta/rs) and theta runs from 0 to 360*rs,
the trefoil knot is obtained if rs:rl = 2:3.
h ~ 0.15*rs, but will depend on the radius of the encircling surface band.
In the program, the z and y functions are reversed.
See comments under "main" for explanation of proc variables
Try, plot 2 3 20, for quick plot; plot 2 3 120 for smoother result
Try rs:rl = (5:8),(3:2)!

-------------
to plot :rs :rl :n
setscene
main :rs :rl .15 100 .12 :n 0 [0 0 0]
polyview
end

to plotpair :rs :rl :n :lor1 :lor2 :offset1 :offset2 ; try plotpair 2 3 60 0
1 [-150 0 0] [150 0 0]
setscene
main :rs :rl .15 80 .12 :n :lor1 :offset1
polyview
main :rs :rl .15 80 .12 :n :lor2 :offset2
polyview
end

to main :rs :rl :fh :size  :fbr :n :lor  :offset
; :rs and :rl should be small, relatively prime integers
; :fh (0 - 1) size of h relative to rs
; :size controls size of plot
; :fbr (0 - 1) radius of band relative to :size
; :n no. of segments /cycle for whole curve
; :lor (values 0 or 1) determines whether knot is left or right handed
; :offset coordinate list
localmake "h :fh*:rs
ifelse :rs=:rl [make "dr 1] [make "dr :rl-:rs]
localmake "fr :rl/:rs
localmake "size1 :size/:dr
setposxyz vecsum :offset (list :size1*(:dr+:h) 0 0) ;position turtle at the
start of curve
setorientation [270 0 270] ;ensures band starts on the 'outside' of curve
pd
for [ang 360/:n 360*:rs 360/:n] ~
    [localmake "tcoord (list :size1*(:dr*(cos :ang )+:h*cos (:dr/:rs*:ang ))
~
                        :size1*sin (:fr*:ang+180*:lor) ~
                        :size1*(:dr*(sin :ang )-:h*sin (:dr/:rs*:ang )) )
       make "tcoord vecsum :offset :tcoord
  setorientation towardsxyz :tcoord
 make "s distancexyz :tcoord
 band fd :s]
pu
end

to band
localmake "theta 6
make "chord 2*:size*:fbr*sin :theta/2
repeat 360/:theta [polystart rect polyend rt 180 lr :theta]
end

to rect
localmake "s1 1.3*:s
fd :s1 rt 90
fd :chord rt 90
fd :s1
rt 90 fd :chord
pu bk :chord lt 90 pd
end

to vecsum :v1 :v2
if empty? :v1 [ [] stop]
op fput (first :v1)+(first :v2) vecsum bf :v1 bf :v2
end

to setscene
cs
pu setpc [0 0 0]
setsc [255 255 255]
setlight [.3 .4]
perspective
setturtle -1
setposxyz [-50 700 100] ; [-300 700 100]
setturtle -2
setorientation towardsxyz [0 0 0]
setturtle 1
pu cs ht
end


to procs
ed[plot plotpair main band rect vecsum setscene]
end



---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home