The Trammel of Archimedes c Skip to output
WH<-c(800,600) #window dimensions
RXY<-c(300,100) #ellipse dimensions
RW<-10 #gap width
dur<-5 #period in seconds
P<-RXY[1]-RXY[2]
thetas<-seq(0,2*pi, length.out=30)
cXY<-lapply(thetas, function(theta){ c( RXY[1]*cos(theta), RXY[2]*sin(theta)) } )
cY<-lapply(thetas, function(theta)-P*sin(theta) )
cX<-lapply(thetas, function(theta) P*cos(theta) )
recenter<-function(cV) lapply(cV, function(v) v-25) #used by rect slider
svgR(wh=WH, viewBox=c(-WH/2, WH),
#background
use(filter=filter( xy=-WH/2, feFlood(flood.color='#CCDDFF') )),
rect(cxy=c(0,0), wh=c(RW,600), fill="white", stroke="none"),
rect(cxy=c(0,0), wh=c(800,RW), fill="white", stroke="none"),
text('Trammel of Archimedes', xy=-WH/2+c(30,30), font.size=30),
#ellipse
ellipse(cxy=c(0,0), rxy=RXY, stroke='red', fill='none'),
#sliders
rect(cxy=c(0,0), wh=c(10,50), stroke="green", fill='lightblue',
animate( attributeName='y', values=recenter(cY), begin=0, dur=dur, repeatCount="indefinite" )
),
rect(cxy=c(P,0),wh=c(50,10), stroke="green", fill='lightblue',
animate( attributeName='x', values=recenter(cX), begin=0, dur=dur, repeatCount="indefinite" )
),
#connecting bar
line(xy1=c(0,0), xy2=c(RXY[1],0), stroke='green', stroke.width=2,
animate( attributeName='y1', values=cY, begin=0, dur=dur, repeatCount="indefinite" ),
animate( attributeName='xy2', values=cXY, begin=0, dur=dur, repeatCount="indefinite" )
),
# pivots
circle(cxy=c(0,0),r=3, fill="green",
animate( attributeName='cy', values=cY, begin=0, dur=dur, repeatCount="indefinite" )
),
circle(cxy=c(P,0),r=3, fill="green",
animate( attributeName='cx', values=cX, begin=0, dur=dur, repeatCount="indefinite" )
),
circle(cxy=c(RXY[1],0),r=5, fill="red",
animate( attributeName='cxy', values=cXY , begin=0, dur=dur, repeatCount="indefinite")
)
)
Note
Description | Value |
---|---|
ellipse dimensions | 300, 100 |
distance between sliders | 100 |
total length of green bar | 300 |