Skip to content

Commit

Permalink
feature: updated ballistics model; edited App.tsx to be compatible wi…
Browse files Browse the repository at this point in the history
…th new wasm module
  • Loading branch information
jcw780 committed Sep 14, 2020
1 parent be35825 commit 6d5b21b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class App extends React.Component<{},{}> {
// Wasm
instance : any; // Wasm Instance
arrayIndices : Record<string, Record<string, number>> = Object.seal({
impactDataIndex: {}, angleDataIndex: {}, postPenDataIndex: {}
impactIndices: {}, angleIndices: {}, postPenIndices: {}
}); //Condensed wasm enums

// Settings Data
Expand Down Expand Up @@ -137,13 +137,13 @@ class App extends React.Component<{},{}> {
}
private makeImpactPoints = (shell, index, dist) => {
const pointFunction = (index, dataType, shell) => {
return this.instance.getImpactPoint(index, this.arrayIndices.impactDataIndex[dataType], shell);
return this.instance.getImpactPoint(index, this.arrayIndices.impactIndices[dataType], shell);
}
return this.makePoint(shell, index, dist, 'impact', pointFunction);
}
private makeAnglePoints = (shell, index, dist) => {
const pointFunction = (index, dataType, shell) => {
return this.instance.getAnglePoint(index, this.arrayIndices.angleDataIndex[dataType], shell);
return this.instance.getAnglePoint(index, this.arrayIndices.angleIndices[dataType], shell);
}
return this.makePoint(shell, index, dist, 'angle', pointFunction);
}
Expand Down Expand Up @@ -218,7 +218,7 @@ class App extends React.Component<{},{}> {
}
}

const {impactDataIndex, postPenDataIndex} = arrayIndices;
const {impactIndices, postPenIndices} = arrayIndices;
let maxDist = 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
Expand All @@ -238,7 +238,7 @@ class App extends React.Component<{},{}> {
const dmConst = radiusOnDelim - (delimSplit * dmSlope);

for(let i=0; i<impactSize; ++i){ // iterate through points at each range
const dist : number = instance.getImpactPoint(i, impactDataIndex.distance, j);
const dist : number = instance.getImpactPoint(i, impactIndices.distance, j);
maxDist = Math.max(maxDist, dist);
//Dispersion
//Note: Sigma correction is technically an approximation.
Expand All @@ -263,7 +263,7 @@ class App extends React.Component<{},{}> {
x: dist, y: maxDispersionStd
});
let maxVertical = maxDispersion /
Math.sin(this.instance.getImpactPoint(i, impactDataIndex.impactAHR, j) * - 1);
Math.sin(this.instance.getImpactPoint(i, impactIndices.impactAHR, j) * - 1);
if(dist < delimSplit){
maxVertical *= (zdSlope * dist + zdConst);
}else{
Expand All @@ -289,9 +289,9 @@ class App extends React.Component<{},{}> {
//Post-Pen
for(let k=0; k<numAngles; ++k){
const detDist : number
= instance.getPostPenPoint(i, postPenDataIndex.x, k, j);
= instance.getPostPenPoint(i, postPenIndices.x, k, j);
const fused : number // = detDist when fused, otherwise = -1
= instance.getPostPenPoint(i, postPenDataIndex.xwf, k, j);
= instance.getPostPenPoint(i, postPenIndices.xwf, k, j);
const point : T.scatterPoint = {x: dist, y: detDist};
// Only draw fused line if fused (fused >= 0); reverse for notFused
if(fused < 0){
Expand Down
4 changes: 2 additions & 2 deletions src/wasm/shellWasm.wasm.js

Large diffs are not rendered by default.

0 comments on commit 6d5b21b

Please sign in to comment.