indexing description: "[ An EM_GOOF_BINARY_FORCE that is mass dependent to represent normal (physically adequate) gravity. ]" date: "$Date$" revision: "$Revision$" class EM_GOOF_GRAVITY inherit EM_GOOF_BINARY_FORCE create make feature {EM_GOOF_FORCE, EM_GOOF_PHYSICS} -- Initialization make(a_strength: DOUBLE) is -- Make the gravity do strength := a_strength end feature {EM_GOOF_FORCE, EM_GOOF_PHYSICS} -- Processing process_objects(object1,object2: EM_GOOF_PHYSICABLE) is -- Apply force between objec1 and object2 local force_vector_1,force_vector_2: EM_VECTOR_2D strength1,strength2: DOUBLE do force_vector_1 := object2.position - object1.position if force_vector_1.length > 0 then force_vector_1.normalize strength1 := strength * object2.mass * object1.mass / (object1.position.distance(object2.position) ^ 2) force_vector_1.stretch(strength1,strength1) end object1.force.add(force_vector_1) force_vector_2 := object1.position - object2.position if force_vector_2.length > 0 then force_vector_2.normalize strength2 := strength * object1.mass * object2.mass / (object2.position.distance(object1.position) ^ 2) force_vector_2.stretch(strength2,strength2) end object2.force.add(force_vector_2) end feature {EM_GOOF_FORCE, EM_GOOF_PHYSICS} -- Properties strength: DOUBLE -- Strength of force set_strength(a_strength: DOUBLE) is -- Set strength do strength := a_strength ensure strength_set: strength = a_strength end end