Skip to content

Commit

Permalink
feature: correctly implemented idealDistance and maxDist
Browse files Browse the repository at this point in the history
  • Loading branch information
jcw780 committed Sep 15, 2020
1 parent 58b9b93 commit 0f7b78d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,27 +219,27 @@ class App extends React.Component<{},{}> {
}

const {impactIndices, postPenIndices} = arrayIndices;
let maxDist = 0; //Maximum Distance for shipWidth
let maxRange = 0; //Maximum Distance for shipWidth
// Converts flat array data format to {x, y} format for chart.js
for(let j=0; j<numShells; ++j){ // iterate through shells
const currentShell = shellData[j];
//Dispersion
const {idealRadius, minRadius, sigmaCount, taperDist,
radiusOnZero, radiusOnDelim, radiusOnMax, delim} = currentShell;
const {idealRadius, minRadius, idealDistance, sigmaCount, taperDist,
radiusOnZero, radiusOnDelim, radiusOnMax, delim, maxDist} = currentShell;
//Horizontal
const hSlope = (idealRadius - minRadius) / 1000, hConst = minRadius * 30;
const hSlope = (idealRadius - minRadius) / idealDistance, hConst = minRadius * 30;
const taperSlope = (hSlope * (taperDist) + hConst) / taperDist!;
//Vertical
const delimSplit = delim * 30000;
const delimSplit = delim * maxDist;
const zdSlope = ((radiusOnDelim - radiusOnZero) / delimSplit);
const zdConst = radiusOnZero;

const dmSlope = ((radiusOnMax - radiusOnDelim) / (30000 - delimSplit));
const dmSlope = ((radiusOnMax - radiusOnDelim) / (maxDist - delimSplit));
const dmConst = radiusOnDelim - (delimSplit * dmSlope);

for(let i=0; i<impactSize; ++i){ // iterate through points at each range
const dist : number = instance.getImpactPoint(i, impactIndices.distance, j);
maxDist = Math.max(maxDist, dist);
maxRange = Math.max(maxRange, dist);
//Dispersion
//Note: Sigma correction is technically an approximation.
//It's just that it is very similar to the exact solution.
Expand All @@ -266,8 +266,10 @@ class App extends React.Component<{},{}> {
Math.sin(this.instance.getImpactPoint(i, impactIndices.impactAHR, j) * - 1);
if(dist < delimSplit){
maxVertical *= (zdSlope * dist + zdConst);
}else{
}else if(dist < 30 * idealDistance){
maxVertical *= (dmSlope * dist + dmConst);
}else{
maxVertical *= (radiusOnMax);
}
const maxVerticalStd = maxVertical / sigmaCount;
dispersion.vertical[j].push({
Expand Down Expand Up @@ -305,7 +307,7 @@ class App extends React.Component<{},{}> {
//Generate Ship Width Line
const {stepSize: sSize} = this.settings.distance;
const stepSize = sSize !== undefined ? sSize: 2000;
const maxAdj = Math.ceil(maxDist / stepSize) * stepSize;
const maxAdj = Math.ceil(maxRange / stepSize) * stepSize;
post.shipWidth = [[],];
const SWE = post.shipWidth.entries();
for(const [, singleShipWidth] of SWE){
Expand Down

0 comments on commit 0f7b78d

Please sign in to comment.