Rework mobility graph to use new getters
This commit is contained in:
@@ -1,78 +0,0 @@
|
|||||||
# =============================================================================
|
|
||||||
# Copyright (C) 2010 Diego Duclos
|
|
||||||
#
|
|
||||||
# This file is part of pyfa.
|
|
||||||
#
|
|
||||||
# pyfa is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# pyfa is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
|
|
||||||
import math
|
|
||||||
|
|
||||||
from .base import FitGraph, XDef, YDef, Input
|
|
||||||
|
|
||||||
|
|
||||||
class FitMobilityVsTimeGraph(FitGraph):
|
|
||||||
|
|
||||||
# UI stuff
|
|
||||||
internalName = 'mobilityGraph'
|
|
||||||
name = 'Mobility'
|
|
||||||
xDefs = [
|
|
||||||
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's'))]
|
|
||||||
yDefs = [
|
|
||||||
YDef(handle='speed', unit='m/s', label='Speed'),
|
|
||||||
YDef(handle='distance', unit='km', label='Distance')]
|
|
||||||
inputs = [
|
|
||||||
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=10, defaultRange=(0, 30))]
|
|
||||||
srcExtraCols = ('Speed', 'Agility')
|
|
||||||
|
|
||||||
# Calculation stuff
|
|
||||||
_denormalizers = {
|
|
||||||
('distance', 'km'): lambda v, fit, tgt: v / 1000}
|
|
||||||
|
|
||||||
def _time2speedFull(self, mainParam, miscParams, fit, tgt):
|
|
||||||
xs = []
|
|
||||||
ys = []
|
|
||||||
maxSpeed = fit.ship.getModifiedItemAttr('maxVelocity')
|
|
||||||
mass = fit.ship.getModifiedItemAttr('mass')
|
|
||||||
agility = fit.ship.getModifiedItemAttr('agility')
|
|
||||||
for time in self._iterLinear(mainParam[1]):
|
|
||||||
# https://wiki.eveuniversity.org/Acceleration#Mathematics_and_formulae
|
|
||||||
speed = maxSpeed * (1 - math.exp((-time * 1000000) / (agility * mass)))
|
|
||||||
xs.append(time)
|
|
||||||
ys.append(speed)
|
|
||||||
return xs, ys
|
|
||||||
|
|
||||||
def _time2distanceFull(self, mainParam, miscParams, fit, tgt):
|
|
||||||
xs = []
|
|
||||||
ys = []
|
|
||||||
maxSpeed = fit.ship.getModifiedItemAttr('maxVelocity')
|
|
||||||
mass = fit.ship.getModifiedItemAttr('mass')
|
|
||||||
agility = fit.ship.getModifiedItemAttr('agility')
|
|
||||||
for time in self._iterLinear(mainParam[1]):
|
|
||||||
# Definite integral of:
|
|
||||||
# https://wiki.eveuniversity.org/Acceleration#Mathematics_and_formulae
|
|
||||||
distance_t = maxSpeed * time + (maxSpeed * agility * mass * math.exp((-time * 1000000) / (agility * mass)) / 1000000)
|
|
||||||
distance_0 = maxSpeed * 0 + (maxSpeed * agility * mass * math.exp((-0 * 1000000) / (agility * mass)) / 1000000)
|
|
||||||
distance = distance_t - distance_0
|
|
||||||
xs.append(time)
|
|
||||||
ys.append(distance)
|
|
||||||
return xs, ys
|
|
||||||
|
|
||||||
_getters = {
|
|
||||||
('time', 'speed'): _time2speedFull,
|
|
||||||
('time', 'distance'): _time2distanceFull}
|
|
||||||
|
|
||||||
|
|
||||||
FitMobilityVsTimeGraph.register()
|
|
||||||
1
gui/builtinGraphs/fitMobility/__init__.py
Normal file
1
gui/builtinGraphs/fitMobility/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import gui.builtinGraphs.fitMobility.graph # noqa: E402,F401
|
||||||
60
gui/builtinGraphs/fitMobility/getter.py
Normal file
60
gui/builtinGraphs/fitMobility/getter.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# Copyright (C) 2010 Diego Duclos
|
||||||
|
#
|
||||||
|
# This file is part of pyfa.
|
||||||
|
#
|
||||||
|
# pyfa is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# pyfa is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
import math
|
||||||
|
|
||||||
|
from gui.builtinGraphs.base import SmoothPointGetter
|
||||||
|
|
||||||
|
|
||||||
|
class Time2SpeedGetter(SmoothPointGetter):
|
||||||
|
|
||||||
|
def _getCommonData(self, miscParams, fit, tgt):
|
||||||
|
return {
|
||||||
|
'maxSpeed': fit.ship.getModifiedItemAttr('maxVelocity'),
|
||||||
|
'mass': fit.ship.getModifiedItemAttr('mass'),
|
||||||
|
'agility': fit.ship.getModifiedItemAttr('agility')}
|
||||||
|
|
||||||
|
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||||
|
maxSpeed = commonData['maxSpeed']
|
||||||
|
mass = commonData['mass']
|
||||||
|
agility = commonData['agility']
|
||||||
|
# https://wiki.eveuniversity.org/Acceleration#Mathematics_and_formulae
|
||||||
|
y = maxSpeed * (1 - math.exp((-x * 1000000) / (agility * mass)))
|
||||||
|
return y
|
||||||
|
|
||||||
|
|
||||||
|
class Time2DistanceGetter(SmoothPointGetter):
|
||||||
|
|
||||||
|
def _getCommonData(self, miscParams, fit, tgt):
|
||||||
|
return {
|
||||||
|
'maxSpeed': fit.ship.getModifiedItemAttr('maxVelocity'),
|
||||||
|
'mass': fit.ship.getModifiedItemAttr('mass'),
|
||||||
|
'agility': fit.ship.getModifiedItemAttr('agility')}
|
||||||
|
|
||||||
|
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||||
|
maxSpeed = commonData['maxSpeed']
|
||||||
|
mass = commonData['mass']
|
||||||
|
agility = commonData['agility']
|
||||||
|
# Definite integral of:
|
||||||
|
# https://wiki.eveuniversity.org/Acceleration#Mathematics_and_formulae
|
||||||
|
distance_t = maxSpeed * x + (maxSpeed * agility * mass * math.exp((-x * 1000000) / (agility * mass)) / 1000000)
|
||||||
|
distance_0 = maxSpeed * 0 + (maxSpeed * agility * mass * math.exp((-0 * 1000000) / (agility * mass)) / 1000000)
|
||||||
|
y = distance_t - distance_0
|
||||||
|
return y
|
||||||
48
gui/builtinGraphs/fitMobility/graph.py
Normal file
48
gui/builtinGraphs/fitMobility/graph.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# Copyright (C) 2010 Diego Duclos
|
||||||
|
#
|
||||||
|
# This file is part of pyfa.
|
||||||
|
#
|
||||||
|
# pyfa is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# pyfa is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
from gui.builtinGraphs.base import FitGraph, XDef, YDef, Input
|
||||||
|
from .getter import Time2SpeedGetter, Time2DistanceGetter
|
||||||
|
|
||||||
|
|
||||||
|
class FitMobilityVsTimeGraph(FitGraph):
|
||||||
|
|
||||||
|
# UI stuff
|
||||||
|
internalName = 'mobilityGraph'
|
||||||
|
name = 'Mobility'
|
||||||
|
xDefs = [
|
||||||
|
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's'))]
|
||||||
|
yDefs = [
|
||||||
|
YDef(handle='speed', unit='m/s', label='Speed'),
|
||||||
|
YDef(handle='distance', unit='km', label='Distance')]
|
||||||
|
inputs = [
|
||||||
|
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=10, defaultRange=(0, 30))]
|
||||||
|
srcExtraCols = ('Speed', 'Agility')
|
||||||
|
|
||||||
|
# Calculation stuff
|
||||||
|
_denormalizers = {
|
||||||
|
('distance', 'km'): lambda v, fit, tgt: v / 1000}
|
||||||
|
|
||||||
|
_getters = {
|
||||||
|
('time', 'speed'): Time2SpeedGetter,
|
||||||
|
('time', 'distance'): Time2DistanceGetter}
|
||||||
|
|
||||||
|
|
||||||
|
FitMobilityVsTimeGraph.register()
|
||||||
Reference in New Issue
Block a user