Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- instance AdditiveGroup GLfloat where {zeroV=0.0; (^+^) = (+); negateV = negate}
- instance VectorSpace GLfloat where
- type Scalar GLfloat = GLfloat
- (*^) = (*)
- instance InnerSpace GLfloat where (<.>) = (*)
- -- Data.VectorSpace it completly braindead, because it defines a scalar
- -- as anything, not as a Field, so that it is not possible the get the
- -- additive identity, so we can't define this on any InnerSpace
- force a b =
- if d == zeroV then
- zeroV
- else
- d ^* factor
- where d = a ^-^ b
- distSq = magnitudeSq d
- -- 1/(r^4) works fine
- -- with usual 1/(r^2) als points
- -- on the border
- factor = 1/(distSq*distSq)
- -- Our point has to be in the unit circle
- limited p
- | d > 1 = p^/d
- | otherwise = p
- where d = magnitude p
- allForces p points = sumV $ map (force p) points
- applyForce p points t = limited $ p ^+^ t *^ (allForces p points)
- transformSystem t points = map (\p -> applyForce p points t) points
Advertisement
Add Comment
Please, Sign In to add comment