Packageexample.orbit.force
Classpublic class GravitationalForceGenerator
ImplementsIForceGenerator



Protected Properties
 PropertyDefined by
  g : Number
gravitational constant
GravitationalForceGenerator
  source : ISimulatable
source of gravitational pull (references mass)
GravitationalForceGenerator
Public Methods
 MethodDefined by
  
GravitationalForceGenerator(source:ISimulatable, gravitationalConstant:Number = 1.2)
Creates the Force Generator
GravitationalForceGenerator
  
generate(element:ISimulatable):void
Generates the gravitational force on the supplied element

We find the source through the following equation:

   F = G m1 m2 / r^2
   
where:
   F is the force we're solving for (applied along the bodies' difference vector)
   G is a gravitational constant
   m1/m2 are the masses involved in the exchange (here, the force is only applied to element)
   r is the distance between the bodies
   

GravitationalForceGenerator
Property detail
gproperty
protected var g:Number

gravitational constant

sourceproperty 
protected var source:ISimulatable

source of gravitational pull (references mass)

Constructor detail
GravitationalForceGenerator()constructor
public function GravitationalForceGenerator(source:ISimulatable, gravitationalConstant:Number = 1.2)

Creates the Force Generator

Parameters
source:ISimulatable — source of gravitational pull
 
gravitationalConstant:Number (default = 1.2) — magic constant (trial and error per simulation)

Throws
— if source has infinite mass
Method detail
generate()method
public function generate(element:ISimulatable):void

Generates the gravitational force on the supplied element

We find the source through the following equation:

   F = G m1 m2 / r^2
   
where:
   F is the force we're solving for (applied along the bodies' difference vector)
   G is a gravitational constant
   m1/m2 are the masses involved in the exchange (here, the force is only applied to element)
   r is the distance between the bodies
   

Parameters
element:ISimulatable — ISimulatable to apply force to