aUCBLogo Demos and Tests / draw_some_ovals
to draw_some_ovals
;inspired by Mike Sandy's post from 22.Nov.2007 to LogoForum
clearScreen
hideTurtle
for [f1 0.5 2 0.1]
[ oval f1 1 [0 -100][200 0] 400
]
end
to oval f1 f2 p1 p2 s
; solve d1*f1+d2*f2=s
; in a first step one-dimensional
setPixel p1 "black
setPixel p2 "black
x2=-Norm p2-p1
x=(s+x2*f1)/(f1+f2)
; now follow the equation's zeroness
p21=(p2-p1)
e1=p21/(Norm p21)
e2=list e1.2 e1.1
p3=p2+e1*x
PenUp
setPos p3
PenDown
oneQuarter -e1 e2
oneQuarter -e1 -e2
oneQuarter e1 -e2
oneQuarter e1 e2
oneQuarter -e1 e2
updateGraph
end
to oneQuarter e1 e2
res=0.1
for [i 1 100000]
[ setPos p3
v1=p3+e1*res
v2=p3+e2*res
o1=ovalness v1
o2=ovalness v2
if o1 > 0.5 and2 o2 > 0.5
[ break
]
ifelse o1 < o2 [p3=v1][p3=v2]
]
end
to ovalness p
output abs (Norm p-p1)*f1+(Norm p-p2)*f2-s
end