module Action ( PBound ,nextPosition3 ,newVelocity3 ) where import Graphics.Rendering.OpenGL import Control.Applicative type PBound= (GLfloat ,GLfloat) 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 pos vel = nextPosition1 <$> pos <*> vel reflectflag :: PBound -> GLfloat -> GLfloat -> Bool reflectflag pB p vel = if (p <= (fst pB) && (vel <= 0.0) ) || (p >= (snd 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