From a7d7542dc646a5fd124ef71e71ce260889f1701b Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 2 Feb 2016 19:24:50 +0100 Subject: Moved to 1415 directory --- files/practicum/support.icl | 47 --------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 files/practicum/support.icl (limited to 'files/practicum/support.icl') diff --git a/files/practicum/support.icl b/files/practicum/support.icl deleted file mode 100644 index 612b00d..0000000 --- a/files/practicum/support.icl +++ /dev/null @@ -1,47 +0,0 @@ -implementation module support - -import StdEnv, StdIO - -toPoint2 :: Size Pos -> Point2 -toPoint2 {w,h} {rx,ry} = {x=toInt ((toReal w)*rx),y=toInt ((toReal h)*ry)} - -fromPoint2 :: Size Point2 -> Pos -fromPoint2 {w,h} {x,y} = {rx=(toReal x)/(toReal w),ry=(toReal y)/(toReal h)} - -circle :: Int -> Oval -circle r = {oval_rx=r,oval_ry=r} - -instance zero Pos where - zero = {rx=zero,ry=zero} -instance zero Vel where - zero = {v0=zero,v1=zero} -instance + Pos where - (+) p1 p2 = {rx=p1.rx+p2.rx,ry=p1.ry+p2.ry} -instance - Pos where - (-) p1 p2 = {rx=p1.rx-p2.rx,ry=p1.ry-p2.ry} -instance + Vel where - (+) a b = {v0=a.v0+b.v0,v1=a.v1+b.v1} -instance - Vel where - (-) a b = {v0=a.v0-b.v0,v1=a.v1-b.v1} - -class scale a :: !Real !a -> a - -instance scale Pos where - scale r p = {rx=r*p.rx,ry=r*p.ry} -instance scale Vel where - scale r v = {v0=r*v.v0,v1=r*v.v1} - -class toVel a :: !a -> Vel - -instance toVel Pos where - toVel p = {v0=p.rx,v1=p.ry} - -class dist a :: !a !a -> Real - -instance dist Pos where - dist p1 p2 = sqrt ((p1.rx - p2.rx)^2.0 + (p1.ry - p2.ry)^2.0) -instance dist Real where - dist r1 r2 = abs (r1 - r2) - -movePos :: Vel Pos -> Pos -movePos v p = {p & rx=p.rx+v.v0,ry=p.ry+v.v1} -- cgit v1.2.3