public virtual void Update(double dt) { ElapsedTime += dt; if (IsPrograde) { DVector2 prograde = SpaceCraft.GetRelativeVelocity(); prograde.Normalize(); SpaceCraft.SetRotation(prograde.Angle()); } if (IsRetrograde) { DVector2 retrograde = SpaceCraft.GetRelativeVelocity(); retrograde.Negate(); retrograde.Normalize(); SpaceCraft.SetRotation(retrograde.Angle()); } }
// Interpolate between current and target orientation over the duration public override void Update(double elapsedTime, ISpaceCraft spaceCraft) { DVector2 prograde = spaceCraft.GetRelativeVelocity(); prograde.Normalize(); double retrogradeAngle = prograde.Angle(); double adjustRatio = (elapsedTime - StartTime) / _adjustmentTime; if (adjustRatio > 1) { spaceCraft.SetRotation(retrogradeAngle); } else { double interpolatedAdjust = _curentOrientation * (1 - adjustRatio) + retrogradeAngle * adjustRatio; spaceCraft.SetRotation(interpolatedAdjust); } }
// Interpolate between current and target orientation over the duration public override void Update(double elapsedTime, ISpaceCraft spaceCraft) { double ratio = (elapsedTime - StartTime) / Duration; spaceCraft.SetRotation(_curentOrientation * (1 - ratio) + _targetOrientation * ratio); }
public override void Finalize(ISpaceCraft spaceCraft) { spaceCraft.SetRotation(_targetOrientation); }