Package com.titan.math.function
Class GravitationFunction
java.lang.Object
com.titan.math.function.GravitationFunction
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
G
public static final double Ggravitational constant- See Also:
-
-
Constructor Details
-
GravitationFunction
public GravitationFunction()
-
-
Method Details
-
f
Calculates all the gravitational forces that are working in the system. Iterates over all the objects based on the masses vector.Gravitational force of all the objects j pulling on object i are calculated with this formula:
F = - sum( G * mi * mj * (pi - pj) / (||pi - pj||^3)
where:
- mi and mj are the masses of the objects i and j
- pi and pj are the positions of the objects i and j- Specified by:
f
in interfaceFunction
- Parameters:
positions
- the positions of the objects (every 3 entries, the next object is referenced)ignore
- this function does not use this vector in its calculationsmasses
- the masses of the objects (same order as in the positions)- Returns:
- a vector of the gravitational forces working in the system
-