Trammel of Archemedes

Trammel of Archemedes
a = Math.Ceiling(Dictionary.ValueAtKey(DateTime.Components(d), "second")*0.58);
ps1 = 3;
xx1 = -5..5..#30;
yy1 = Math.Sqrt(ps1*ps1-Math.Pow(xx1,2));
sg1 = List.FilterByBoolMask(Math.Sign(xx1),yy1>0)["in"];
xx2 = Math.Round(List.FilterByBoolMask(xx1,yy1>0)["in"],6);
yy2 = Math.Round(List.FilterByBoolMask(yy1,yy1>0)["in"],6)*sg1;
pv1 = Point.ByCoordinates(xx2);
pv2 = Point.ByCoordinates(0,yy2);
ln1 = List.Flatten(Line.ByStartPointEndPoint(pv1,[pv2,List.Reverse(pv2)]<1>),-1);
an1 = ln1.ExtendEnd(3).EndPoint.AsVector().AngleAboutAxis(Vector.XAxis(),Vector.ZAxis());
ln2 = List.SortByKey(ln1,an1)["sortedList"];
ln3 = List.GetItemAtIndex(ln2,a);
//Solids
cl1 = Circle.ByCenterPointRadius(ln3.StartPoint,0.07).ExtrudeAsSolid(Vector.ZAxis(),0.125);
cl2 = Circle.ByCenterPointRadius(ln3.EndPoint,0.07).ExtrudeAsSolid(Vector.ZAxis(),0.125);
cl3 = Circle.ByCenterPointRadius(ln3.ExtendEnd(4.15).EndPoint,0.1).ExtrudeAsSolid(Vector.ZAxis(),0.15);
ln4 = PolyCurve.ByThickeningCurveNormal(ln3.ExtendEnd(4.5).ExtendStart(0.15),0.5,Vector.ZAxis()).ExtrudeAsSolid(Vector.ZAxis(),0.05);
rt1 = Rectangle.ByWidthLength(0.75,0.5).Translate(Vector.XAxis(),ln3.StartPoint.X).ExtrudeAsSolid(Vector.ZAxis(),-0.2);
rt2 = Rectangle.ByWidthLength(0.5,0.75).Translate(Vector.YAxis(),ln3.EndPoint.Y).ExtrudeAsSolid(Vector.ZAxis(),-0.2);
rt3 = Rectangle.ByWidthLength(3,3).Translate([1.75,1.75,-1.75,-1.75],[1.75,-1.75,-1.75,1.75],-0.1).ExtrudeAsSolid(Vector.ZAxis(),-0.1);
rt4 = Solid.ByUnion(List.Flatten([rt3,Rectangle.ByWidthLength(6.5,6.5).Translate(0,0,-0.2).ExtrudeAsSolid(Vector.ZAxis(),-0.3)],-1));
//Color
cr1 = GeometryColor.ByGeometryColor(ln4,Color.ByARGB(255,204,102,0));
cr2 = GeometryColor.ByGeometryColor([rt1,rt2],Color.ByARGB(255,255,255,0));
cr3 = GeometryColor.ByGeometryColor(rt4,Color.ByARGB(255,255,255,200));
cr4 = GeometryColor.ByGeometryColor([cl1,cl2,cl3],Color.ByARGB(255,0,255,200));