Change internal interfaces a little
This commit is contained in:
@@ -28,11 +28,11 @@ class PointGetter(metaclass=ABCMeta):
|
||||
self.graph = graph
|
||||
|
||||
@abstractmethod
|
||||
def getRange(self, mainParamRange, miscParams, fit, tgt):
|
||||
def getRange(self, xRange, miscParams, fit, tgt):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def getPoint(self, mainParam, miscParams, fit, tgt):
|
||||
def getPoint(self, x, miscParams, fit, tgt):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class SmoothPointGetter(PointGetter, metaclass=ABCMeta):
|
||||
self._baseResolution = baseResolution
|
||||
self._extraDepth = extraDepth
|
||||
|
||||
def getRange(self, mainParamRange, miscParams, fit, tgt):
|
||||
def getRange(self, xRange, miscParams, fit, tgt):
|
||||
xs = []
|
||||
ys = []
|
||||
commonData = self._getCommonData(miscParams=miscParams, fit=fit, tgt=tgt)
|
||||
@@ -61,7 +61,7 @@ class SmoothPointGetter(PointGetter, metaclass=ABCMeta):
|
||||
prevX = None
|
||||
prevY = None
|
||||
# Go through X points defined by our resolution setting
|
||||
for x in self._xIterLinear(mainParamRange[1]):
|
||||
for x in self._xIterLinear(xRange):
|
||||
y = self._calculatePoint(x=x, miscParams=miscParams, fit=fit, tgt=tgt, commonData=commonData)
|
||||
if prevX is not None and prevY is not None:
|
||||
# And if Y values of adjacent data points are not equal, add extra points
|
||||
@@ -73,11 +73,9 @@ class SmoothPointGetter(PointGetter, metaclass=ABCMeta):
|
||||
ys.append(y)
|
||||
return xs, ys
|
||||
|
||||
def getPoint(self, mainParam, miscParams, fit, tgt):
|
||||
def getPoint(self, x, miscParams, fit, tgt):
|
||||
commonData = self._getCommonData(miscParams=miscParams, fit=fit, tgt=tgt)
|
||||
x = mainParam[1]
|
||||
y = self._calculatePoint(x=x, miscParams=miscParams, fit=fit, tgt=tgt, commonData=commonData)
|
||||
return x, y
|
||||
return self._calculatePoint(x=x, miscParams=miscParams, fit=fit, tgt=tgt, commonData=commonData)
|
||||
|
||||
def _xIterLinear(self, xRange):
|
||||
xLow = min(xRange)
|
||||
|
||||
@@ -139,7 +139,7 @@ class FitGraph(metaclass=ABCMeta):
|
||||
def _calcPlotPoints(self, mainInput, miscInputs, xSpec, ySpec, fit, tgt):
|
||||
mainParamRange, miscParams = self._normalizeInputs(mainInput=mainInput, miscInputs=miscInputs, fit=fit, tgt=tgt)
|
||||
mainParamRange, miscParams = self._limitParams(mainParamRange=mainParamRange, miscParams=miscParams, fit=fit, tgt=tgt)
|
||||
xs, ys = self._getPoints(mainParamRange=mainParamRange, miscParams=miscParams, xSpec=xSpec, ySpec=ySpec, fit=fit, tgt=tgt)
|
||||
xs, ys = self._getPoints(xRange=mainParamRange[1], miscParams=miscParams, xSpec=xSpec, ySpec=ySpec, fit=fit, tgt=tgt)
|
||||
ys = self._denormalizeValues(ys, ySpec, fit, tgt)
|
||||
# Sometimes x denormalizer may fail (e.g. during conversion of 0 ship speed to %).
|
||||
# If both inputs and outputs are in %, do some extra processing to at least have
|
||||
@@ -211,14 +211,14 @@ class FitGraph(metaclass=ABCMeta):
|
||||
|
||||
_getters = {}
|
||||
|
||||
def _getPoints(self, mainParamRange, miscParams, xSpec, ySpec, fit, tgt):
|
||||
def _getPoints(self, xRange, miscParams, xSpec, ySpec, fit, tgt):
|
||||
try:
|
||||
getterClass = self._getters[(xSpec.handle, ySpec.handle)]
|
||||
except KeyError:
|
||||
return [], []
|
||||
else:
|
||||
getter = getterClass(graph=self)
|
||||
return getter.getRange(mainParamRange=mainParamRange, miscParams=miscParams, fit=fit, tgt=tgt)
|
||||
return getter.getRange(xRange=xRange, miscParams=miscParams, fit=fit, tgt=tgt)
|
||||
|
||||
_denormalizers = {}
|
||||
|
||||
|
||||
@@ -31,11 +31,12 @@ class Time2CapAmountGetter(SmoothPointGetter):
|
||||
'capRegenTime': fit.ship.getModifiedItemAttr('rechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
y = calculateCapAmount(
|
||||
time = x
|
||||
capAmount = calculateCapAmount(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
time=x)
|
||||
return y
|
||||
time=time)
|
||||
return capAmount
|
||||
|
||||
|
||||
class Time2CapRegenGetter(SmoothPointGetter):
|
||||
@@ -46,22 +47,24 @@ class Time2CapRegenGetter(SmoothPointGetter):
|
||||
'capRegenTime': fit.ship.getModifiedItemAttr('rechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
time = x
|
||||
currentCapAmount = calculateCapAmount(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
time=x)
|
||||
y = calculateCapRegen(
|
||||
time=time)
|
||||
capRegen = calculateCapRegen(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
currentCapAmount=currentCapAmount)
|
||||
return y
|
||||
return capRegen
|
||||
|
||||
|
||||
# Useless, but valid combination of x and y
|
||||
class CapAmount2CapAmountGetter(SmoothPointGetter):
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
return x
|
||||
capAmount = x
|
||||
return capAmount
|
||||
|
||||
|
||||
class CapAmount2CapRegenGetter(SmoothPointGetter):
|
||||
@@ -72,11 +75,12 @@ class CapAmount2CapRegenGetter(SmoothPointGetter):
|
||||
'capRegenTime': fit.ship.getModifiedItemAttr('rechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
y = calculateCapRegen(
|
||||
capAmount = x
|
||||
capRegen = calculateCapRegen(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
currentCapAmount=x)
|
||||
return y
|
||||
currentCapAmount=capAmount)
|
||||
return capRegen
|
||||
|
||||
|
||||
def calculateCapAmount(maxCapAmount, capRegenTime, time):
|
||||
|
||||
@@ -137,6 +137,7 @@ class XDistanceMixin(SmoothPointGetter):
|
||||
'dmgMap': self._getDamagePerKey(fit=fit, time=miscParamMap['time'])}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
distance = x
|
||||
miscParamMap = commonData['miscParamMap']
|
||||
tgtSpeed = miscParamMap['tgtSpeed']
|
||||
tgtSigRadius = getTgtSigRadius(tgt)
|
||||
@@ -151,7 +152,7 @@ class XDistanceMixin(SmoothPointGetter):
|
||||
webMods=webMods,
|
||||
webDrones=webDrones,
|
||||
webFighters=webFighters,
|
||||
distance=x)
|
||||
distance=distance)
|
||||
tgtSigRadius = tgtSigRadius * getTpMult(
|
||||
fit=fit,
|
||||
tgt=tgt,
|
||||
@@ -159,13 +160,13 @@ class XDistanceMixin(SmoothPointGetter):
|
||||
tpMods=tpMods,
|
||||
tpDrones=tpDrones,
|
||||
tpFighters=tpFighters,
|
||||
distance=x)
|
||||
distance=distance)
|
||||
applicationMap = getApplicationPerKey(
|
||||
fit=fit,
|
||||
tgt=tgt,
|
||||
atkSpeed=miscParamMap['atkSpeed'],
|
||||
atkAngle=miscParamMap['atkAngle'],
|
||||
distance=x,
|
||||
distance=distance,
|
||||
tgtSpeed=tgtSpeed,
|
||||
tgtAngle=miscParamMap['tgtAngle'],
|
||||
tgtSigRadius=tgtSigRadius)
|
||||
@@ -212,10 +213,10 @@ class XTimeMixin(PointGetter):
|
||||
tgtSigRadius=tgtSigRadius)
|
||||
return applicationMap
|
||||
|
||||
def getRange(self, mainParamRange, miscParams, fit, tgt):
|
||||
def getRange(self, xRange, miscParams, fit, tgt):
|
||||
xs = []
|
||||
ys = []
|
||||
minTime, maxTime = mainParamRange[1]
|
||||
minTime, maxTime = xRange
|
||||
# Prepare time cache and various shared data
|
||||
self._prepareTimeCache(fit=fit, maxTime=maxTime)
|
||||
timeCache = self._getTimeCacheData(fit=fit)
|
||||
@@ -266,14 +267,14 @@ class XTimeMixin(PointGetter):
|
||||
ys.append(currentDmg or 0)
|
||||
return xs, ys
|
||||
|
||||
def getPoint(self, mainParam, miscParams, fit, tgt):
|
||||
x = mainParam[1]
|
||||
def getPoint(self, x, miscParams, fit, tgt):
|
||||
time = x
|
||||
# Prepare time cache and various data
|
||||
self._prepareTimeCache(fit=fit, maxTime=x)
|
||||
dmgData = self._getTimeCacheDataPoint(fit=fit, time=x)
|
||||
self._prepareTimeCache(fit=fit, maxTime=time)
|
||||
dmgData = self._getTimeCacheDataPoint(fit=fit, time=time)
|
||||
applicationMap = self._prepareApplicationMap(miscParams=miscParams, fit=fit, tgt=tgt)
|
||||
y = applyDamage(dmgMap=dmgData, applicationMap=applicationMap).total
|
||||
return x, y
|
||||
return y
|
||||
|
||||
|
||||
class XTgtSpeedMixin(SmoothPointGetter):
|
||||
@@ -290,8 +291,8 @@ class XTgtSpeedMixin(SmoothPointGetter):
|
||||
'dmgMap': self._getDamagePerKey(fit=fit, time=miscParamMap['time'])}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
miscParamMap = commonData['miscParamMap']
|
||||
tgtSpeed = x
|
||||
miscParamMap = commonData['miscParamMap']
|
||||
tgtSigRadius = getTgtSigRadius(tgt)
|
||||
if commonData['applyProjected']:
|
||||
webMods, tpMods = self.graph._projectedCache.getProjModData(fit)
|
||||
@@ -363,8 +364,8 @@ class XTgtSigRadiusMixin(SmoothPointGetter):
|
||||
'dmgMap': self._getDamagePerKey(fit=fit, time=miscParamMap['time'])}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
tgtSigRadius = x
|
||||
miscParamMap = commonData['miscParamMap']
|
||||
tgtSigRadius = x * commonData['tgtSigMult']
|
||||
applicationMap = getApplicationPerKey(
|
||||
fit=fit,
|
||||
tgt=tgt,
|
||||
@@ -373,7 +374,7 @@ class XTgtSigRadiusMixin(SmoothPointGetter):
|
||||
distance=miscParamMap['distance'],
|
||||
tgtSpeed=commonData['tgtSpeed'],
|
||||
tgtAngle=miscParamMap['tgtAngle'],
|
||||
tgtSigRadius=tgtSigRadius)
|
||||
tgtSigRadius=tgtSigRadius * commonData['tgtSigMult'])
|
||||
y = applyDamage(dmgMap=commonData['dmgMap'], applicationMap=applicationMap).total
|
||||
return y
|
||||
|
||||
|
||||
@@ -32,12 +32,13 @@ class Time2SpeedGetter(SmoothPointGetter):
|
||||
'agility': fit.ship.getModifiedItemAttr('agility')}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
time = x
|
||||
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
|
||||
speed = maxSpeed * (1 - math.exp((-time * 1000000) / (agility * mass)))
|
||||
return speed
|
||||
|
||||
|
||||
class Time2DistanceGetter(SmoothPointGetter):
|
||||
@@ -49,12 +50,13 @@ class Time2DistanceGetter(SmoothPointGetter):
|
||||
'agility': fit.ship.getModifiedItemAttr('agility')}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
time = x
|
||||
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_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)
|
||||
y = distance_t - distance_0
|
||||
return y
|
||||
distance = distance_t - distance_0
|
||||
return distance
|
||||
|
||||
@@ -31,11 +31,12 @@ class Time2ShieldAmountGetter(SmoothPointGetter):
|
||||
'shieldRegenTime': fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
y = calculateShieldAmount(
|
||||
time = x
|
||||
shieldAmount = calculateShieldAmount(
|
||||
maxShieldAmount=commonData['maxShieldAmount'],
|
||||
shieldRegenTime=commonData['shieldRegenTime'],
|
||||
time=x)
|
||||
return y
|
||||
time=time)
|
||||
return shieldAmount
|
||||
|
||||
|
||||
class Time2ShieldRegenGetter(SmoothPointGetter):
|
||||
@@ -46,22 +47,24 @@ class Time2ShieldRegenGetter(SmoothPointGetter):
|
||||
'shieldRegenTime': fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
time = x
|
||||
currentShieldAmount = calculateShieldAmount(
|
||||
maxShieldAmount=commonData['maxShieldAmount'],
|
||||
shieldRegenTime=commonData['shieldRegenTime'],
|
||||
time=x)
|
||||
y = calculateShieldRegen(
|
||||
time=time)
|
||||
shieldRegen = calculateShieldRegen(
|
||||
maxShieldAmount=commonData['maxShieldAmount'],
|
||||
shieldRegenTime=commonData['shieldRegenTime'],
|
||||
currentShieldAmount=currentShieldAmount)
|
||||
return y
|
||||
return shieldRegen
|
||||
|
||||
|
||||
# Useless, but valid combination of x and y
|
||||
class ShieldAmount2ShieldAmountGetter(SmoothPointGetter):
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
return x
|
||||
shieldAmount = x
|
||||
return shieldAmount
|
||||
|
||||
|
||||
class ShieldAmount2ShieldRegenGetter(SmoothPointGetter):
|
||||
@@ -72,11 +75,12 @@ class ShieldAmount2ShieldRegenGetter(SmoothPointGetter):
|
||||
'shieldRegenTime': fit.ship.getModifiedItemAttr('shieldRechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
y = calculateShieldRegen(
|
||||
shieldAmount = x
|
||||
shieldRegen = calculateShieldRegen(
|
||||
maxShieldAmount=commonData['maxShieldAmount'],
|
||||
shieldRegenTime=commonData['shieldRegenTime'],
|
||||
currentShieldAmount=x)
|
||||
return y
|
||||
currentShieldAmount=shieldAmount)
|
||||
return shieldRegen
|
||||
|
||||
|
||||
def calculateShieldAmount(maxShieldAmount, shieldRegenTime, time):
|
||||
|
||||
@@ -34,11 +34,12 @@ class Distance2TimeGetter(SmoothPointGetter):
|
||||
'warpSpeed': fit.warpSpeed}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
y = calculate_time_in_warp(
|
||||
distance = x
|
||||
time = calculate_time_in_warp(
|
||||
max_subwarp_speed=commonData['subwarpSpeed'],
|
||||
max_warp_speed=commonData['warpSpeed'],
|
||||
warp_dist=x)
|
||||
return y
|
||||
warp_dist=distance)
|
||||
return time
|
||||
|
||||
|
||||
# Taken from https://wiki.eveuniversity.org/Warp_time_calculation#Implementation
|
||||
|
||||
Reference in New Issue
Block a user