module Action ( PBound(..) ,nextPosition3 ,newVelocity3 ) where import Graphics.Rendering.OpenGL import Control.Applicative data PBound = PBound { minBorder :: GLfloat ,maxBorder :: GLfloat } deriving(Show) nextVelocity1 :: GLfloat -> GLfloat -> GLfloat nextVelocity1 acc vel = vel + acc nextPosition1 :: GLfloat -> GLfloat -> GLfloat nextPosition1 pos vel = pos + vel nextPosition3 :: Vector3(GLfloat) -> Vector3(GLfloat) -> Vector3(GLfloat) nextPosition3 (Vector3 p1 p2 p3) (Vector3 v1 v2 v3) = Vector3 (p1 + v1) (p2 + v2) (p3 + v3) reflectflag :: PBound -> GLfloat -> GLfloat -> Bool reflectflag pB p vel = if (p <= (minBorder pB) && (vel <= 0.0) ) || (p >= (maxBorder pB) && (vel >= 0.0)) then True else False newVelecity1 ::PBound -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GLfloat newVelecity1 pB refc pos acc vel = if (reflectflag pB pos vel) then ( -vel * refc) else (nextVelocity1 acc vel) newVelocity3 :: Vector3(PBound) -> Vector3(GLfloat) -> Vector3(GLfloat) -> Vector3(GLfloat) -> Vector3(GLfloat) -> Vector3(GLfloat) newVelocity3 pB refc pos acc vel = newVelecity1 <$> pB <*> refc <*> pos <*> acc <*> vel