private double CalculateMagnitude(double currentStrength, double elapsedTime) { // Add to history _magnitudeHistory.StoreMagnitude(currentStrength, elapsedTime); // Figure out the percent return(SensorGravity.CalculateMagnitudePercent(currentStrength, _magnitudeHistory.CurrentMax)); }
public void Update_AnyThread(double elapsedTime) { lock (_lock) { if (this.IsDestroyed || _energyTanks == null || _energyTanks.RemoveQuantity(elapsedTime * _volume * _itemOptions.SpinSensor_AmountToDraw * ItemOptions.ENERGYDRAWMULT, true) > 0d) { // The energy tank didn't have enough //NOTE: To be clean, I should set the neuron outputs to zero, but anything pulling from them should be checking this //anyway. So save the processor (also, because of threading, setting them to zero isn't as atomic as this property) _isOn = false; return; } _isOn = true; //Vector3D angularVelocity = GetAngularVelocityModelCoords(); // this shouldn't be translated to model coords, it makes the vector appear to wobble even when the ship has a constant angular velocity var worldSpeed = GetWorldSpeed(null); // Figure out the magnitude to use double magnitude = SensorGravity.CalculateMagnitudePercent(worldSpeed.Item2.Length, _itemOptions.SpinSensor_MaxSpeed); SensorGravity.UpdateNeurons(_neurons, _neuronMaxRadius, worldSpeed.Item2, magnitude); } }