-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathUtils.hs
27 lines (18 loc) · 923 Bytes
/
Utils.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Utils where
import FRP.Yampa.Vector3
import Graphics.UI.GLUT hiding (Level,Vector3(..),normalize)
import Types
p3DtoV3 :: (RealFloat a) => Point3D -> Vector3 a
p3DtoV3 (P3D x y z) = vector3 (fromInteger x) (fromInteger y) (fromInteger z)
vectorApply f v = vector3 (f $ vector3X v) (f $ vector3Y v) (f $ vector3Z v)
vector3Rotate' :: (Integral a, RealFloat b) => a -> Vector3 b -> Vector3 b
vector3Rotate' theta v =
let rotateTheta 0 v = id v
rotateTheta 1 v = vector3 (vector3X v) (vector3Z v) (-(vector3Y v))
rotateTheta 2 v = vector3 (vector3X v) (-(vector3Y v)) (-(vector3Z v))
rotateTheta 3 v = vector3 (vector3X v) (-(vector3Z v)) (vector3Y v)
rotateTheta i _ = rotateTheta (abs $ i `mod` 4) v
in rotateTheta theta $ v
-- TODO: Memoize
size :: Level -> Integer
size = (+1) . maximum . map (\(P3D x y z) -> maximum [x,y,z]) . obstacles