Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data Circle = Cir {cx,cy,cr :: Float, v :: Vector}
  2.     deriving(Show)
  3. data Point = Pt {pointx, pointy :: Float}
  4.     deriving(Show)
  5. data Vector = Vec {alfa,velocity::Float}
  6.     deriving(Show)
  7.  
  8. intersects :: Circle -> Circle -> Bool
  9. intersects (Cir {cx=x,cy=y,cr=r,v=Vec {alfa = deg, velocity=speed}}) (Cir {cx=a,cy=b,cr=c, v=Vec {alfa = w, velocity=vel}}) = ((x-a)*(x-a)+(y-b)*(y-b))<(r+c)*(r+c)
  10.  
  11. megfordul :: Circle -> Circle
  12. megfordul (Cir {cx=x,cy=y,cr=r, v=Vec {alfa = deg, velocity=speed}}) = Cir x y r (Vec (deg+180) speed)
  13.  
  14. degRad x = x*pi/180
  15.  
  16. mozdul :: Circle -> Circle
  17. mozdul (Cir {cx=x,cy=y,cr=r, v=Vec {alfa = deg, velocity=speed}}) = Cir (x+speed*(cos (degRad deg))) (y+speed*(sin (degRad deg))) r (Vec deg speed)
  18.  
  19. elso = Cir 0 0 1 (Vec 180 1)
  20. masodik = Cir 0 1 1 (Vec 90 2)
  21.  
  22. hatv_rel f x 1 = f x
  23. hatv_rel f x n = f (hatv_rel f x (n-1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement