clock

CLASS MetalMaterial(color::IsRGBcolor)
ISA BaseMaterial =
<diffuse,specular,ambient,emissive,shininess,transparency>
WHERE
diffuse = color,
specular = diffuse,
ambient = 0.2,
emissive = BLACK,
shininess = 0.8,
transparency = 0
END;
DEF Sphere2 (radius::IsReal)(latN,latS,long::IsReal)(n,m::IsIntPos)=
MAP:[fx,fy,fz]:domain
WHERE
fx = K:radius * -~SIN~v * COS~u,
fy = K:radius * COS~u * COS~v,
fz = K:radius * SIN~u,
u=S1, v=S2,
domain= Interval:<latS*PI/-2,latN*PI/2>:n * Interval:<0,2*PI*long>:m,
interval (a,b::IsReal)(n::IsInt) = (T:1:a ~ QUOTE ~ #:n):((b - a)/n)
END;
def hour_arm(h::IsInt)=(R:<1,2>:(-2*h*PI/12)):((T:<1,2>:<-1/2,-1/2>): (cuboid:<1,8,0.1> MATERIAL (MetalMaterial:(RGBcolor:<0.1,0.2,0.3>))));
def minute_arm(m::IsInt)=(R:<1,2>:(-2*m*PI/60)): ((T:<1,2>:<-1/2,-1/2>): (cuboid:<1,9,0.2> MATERIAL (MetalMaterial:(RGBcolor:<0.1,0.2,0.3>))));
def second_arm(s::IsInt)=(R:<1,2>:(-2*s*PI/60)): ((T:<1,2>:<-0.05,-1.5>): (cuboid:<0.1,11,0.1> COLOR BLACK));
Def casing = STRUCT:<face,ticks,bottomcase,topcase,pirulu>
WHERE face=(S:<1,2>:<10,10>:(Circle:1:<60,1>)) COLOR WHITE,
tick = ((T:2:9)~(T:<1,2>:<-1/2,-1/2>)):(cuboid:<1,1,0.1> MATERIAL
(MetalMaterial:(RGBcolor:<0.1,0.2,0.3>))),
ticks=STRUCT:(CONS:(AA:((R:<1,2>)~*~[ID,K:(2*PI/12)]):(0..11)):tick),
bottomcase = (Sphere2:10:<0,1,1>:<8,60>) MATERIAL (MetalMaterial:YELLOW),
topcase = (Sphere2:10:<1,0,1>:<8,60>) MATERIAL Transparentmaterial:<BLUE,0.8>, pirulu=Cone:<0.5,1>:12
END;
def pod = (MKPOL:<<<0,0,-1>,<0,-10,-10>,<-10,-10,-1>,<10,-10,-1>>,<<1,2,3,4>>,<<1>>>) MATERIAL (MetalMaterial:(RGBcolor:<0.1,0.2,0.3>));
def clock=STRUCT:<
FRAME:casing:<0,-1>,
FRAME:pod:<0,-1>,
t:3:0.2,
WARP:3600: (MOVE:hour_arm: (0..12):(0..12)),
t:3:0.2,
LOOP:12,
WARP:60: (move:minute_arm: (0..59):(0..59)),
t:3:0.2,
LOOP:60,
move:second_arm:(0..59):(0..59)
>;
def out=clock;