module Goal.Simulation.Physics.Models.Pendulum where --- Imports --- -- Goal -- import Goal.Geometry import Goal.Simulation.Physics.Configuration --- Penduli --- data Pendulum = Pendulum Double Double deriving (Eq, Read, Show) --- Instances --- instance Manifold Pendulum where dimension _ = 1 instance Riemannian Generalized Pendulum where metric q = let (Pendulum m l) = manifold q in fromList (Tensor (Tangent q) (Tangent q)) [m*l^2] instance Conservative Gravity Pendulum where potentialEnergy (Gravity g) q = let (Pendulum m l) = manifold q [tht] = listCoordinates q in m * g * l * (1 - cos tht) instance ForceField Gravity Pendulum where force (Gravity g) qdq = let q = position qdq (Pendulum m l) = manifold q [tht] = listCoordinates q in fromList (Tangent $ velocity qdq) [-m*g*l*sin tht]