## Emerging Ellipse

smbstarv
Posts: 74
Joined: Wed Nov 27, 2013 3:44 pm
My devices: Ipad 6th gen
Flag:
Contact:

### Emerging Ellipse

REM*****edited by INDENTATOR 2.0 on 21-7-2021
/*
Draw many lines from an arbitrary point...
in a circle to its circumference.
Rotate each by 90 degrees around its centre.
What emerges is a perfect ellipse.
(from: Feynman's lost lecture)
*/
SET ORIENTATION LANDSCAPE
SET BUTTONS FONT SIZE 40
BUTTON ">" TEXT "next" AT 900,600 SIZE 80,80
GRAPHICS
OPTION ANGLE DEGREES
p=300
q=300
r=200 'circle
a=210
b=390 'arbitrary point
DRAW TEXT "Draw an arbitrary line..." AT 600,100
DRAW TEXT "...from an arbitrary..." AT 600,130
DRAW TEXT "...excentric point in a circle..." AT 600,160
DRAW TEXT "...to its circumference." AT 600,190
DRAW CIRCLE p,q SIZE r
DRAW CIRCLE p,q SIZE 2
DRAW CIRCLE a,b SIZE 3
m=5
f=b-m*a
g=f-q
u=1+m*m
v=2*g*m-2*p
w=p*p+g*g-r*r
x1=(-v-SQR(v*v-4*u*w))/2/u
y1=m*x1+f
DRAW LINE a,b TO x1,y1 'line to circumference

nxt()

DRAW TEXT "Rotate that line by..." AT 600,250
DRAW TEXT "...90 degrees around its centre." AT 600,280
'
xm=(x1+a)/2
ym=(y1+b)/2
yr1=-1/m+ym+xm/m
yr2=-1400/m+ym+xm/m
DRAW LINE 1,yr1 TO 1400,yr2 'perpendicular line
DRAW COLOR 0,0,0
DRAW LINE a,b TO x1,y1 'wipe line to circumference
DRAW COLOR 1,1,1

nxt()
'
DRAW TEXT "...and now with more random lines..." AT 600,350
nxt()

FOR ct=1 TO 100 STEP 1
lp:m=TAN(RND(360))
IF m=0 THEN GOTO lp
'
f=b-m*a
g=f-q
u=1+m^2
v=2*g*m-2*p
w=p^2+g^2-r^2

x1=(-v-SQR(v*v-4*u*w))/2/u
x2=(-v+SQR(v*v-4*u*w))/2/u
y1=m*x1+f
y2=m*x2+f

x1m=(x1+a)/2
y1m=(y1+b)/2 'coordinates of rotationpoint
x2m=(x2+a)/2
y2m=(y2+b)/2

yr1=-1/m+y1m+x1m/m
yr2=-1400/m+y1m+x1m/m
DRAW LINE 1,yr1 TO 1400,yr2

yr1=-1/m+y2m+x2m/m
yr2=-1400/m+y2m+x2m/m
DRAW LINE 1,yr1 TO 1400,yr2
PAUSE 1/ct
NEXT ct

DRAW FONT SIZE 30
DRAW TEXT "...A PERFECT ELLIPSE ! " AT 600,400

DEF nxt
BUTTON ">" SHOW
DO
SLOWDOWN
UNTIL BUTTON_PRESSED(">")
BUTTON ">" HIDE
END DEF