package entities;
public class Acceleration {
private double massValue = 1.0;
private Pair<Double> forceValue = new Pair<>(0d, 0d);
private Velocity velocity;
private Onground onground;
private Pair<Double> value = new Pair<>(0d, 0d);
//---------------------------------------------------------------
//
public void updateByMass(double mass) {
this.massValue = mass;
Pair<Double> temp_l0;
if (this.onground.getOnground()) temp_l0 = new Pair((forceValue.getFirst() / mass), 0.0);
else temp_l0 = new Pair((forceValue.getFirst() / mass), (forceValue.getSecond() / mass));
this.value = temp_l0;
velocity.updateByAcceleration(value);
}
//---------------------------------------------------------------
//
public void updateByForce(Pair<Double> force) {
this.forceValue = force;
Pair<Double> temp_l1;
if (this.onground.getOnground()) temp_l1 = new Pair((force.getFirst() / massValue), 0.0);
temp_l1 = new Pair((force.getFirst() / massValue), (force.getSecond() / massValue));
value = temp_l1;
velocity.updateByAcceleration(value);
}
//---------------------------------------------------------------
//---------------------------------------------------------------
public Acceleration(Velocity velocity, Onground onground) {
this.velocity = velocity;
this.onground = onground;
}
//---------------------------------------------------------------
//
public Pair<Double> getValue() {
return value;
}
}