Skip to content

Commit

Permalink
Added paladin drag
Browse files Browse the repository at this point in the history
  • Loading branch information
habitualdev committed Dec 18, 2023
1 parent 4d26870 commit bb1de29
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
1 change: 1 addition & 0 deletions ArtyCalc.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion drag.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"2B14-1 Podnos" : -0.00006,
"M224 (ACE)": -0.00006,
"M270 MLRS": -0.00006,
"MK45 Hammer": -0.00006
"MK45 Hammer": -0.00006,
"M109A6 Paladin": -0.00006
}
44 changes: 39 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"image"
"image/png"
"math"
"net/http"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -605,19 +606,52 @@ func GraphShotDrag(dataPoints plotter.XYs, distance float64, lowHigh string) ima

}

func GetLatestNumbers() Guns {
tempGuns := Guns{}
resp, err := http.Get("https://raw.githubusercontent.com/habitualdev/ArtyCalc/main/artillery.json")
if err != nil {
err = json.Unmarshal(artilleryJson, &tempGuns)
return tempGuns
}
defer resp.Body.Close()
buf := []byte{}
resp.Body.Read(buf)
err = json.Unmarshal(buf, &tempGuns)
if err != nil {
err = json.Unmarshal(artilleryJson, &tempGuns)
return tempGuns
}
return tempGuns
}

func GetLatestNumbersDrag() DragTable {
artyDrag := DragTable{}
resp, err := http.Get("https://raw.githubusercontent.com/habitualdev/ArtyCalc/main/drag.json")
if err != nil {
err = json.Unmarshal(dragTable, &artyDrag)
return artyDrag
}
defer resp.Body.Close()
buf := []byte{}
resp.Body.Read(buf)
err = json.Unmarshal(buf, &artyDrag)
if err != nil {
err = json.Unmarshal(dragTable, &artyDrag)
return artyDrag
}
return artyDrag
}

func main() {
lastCalcMission := FireMission{}
var savedMissions FireMissions
var err error
airResistanceBool := false
guns := Guns{}

curGun := Gun{}

err = json.Unmarshal(artilleryJson, &guns)
if err != nil {
return
}
guns = GetLatestNumbers()
dragTableJson = GetLatestNumbersDrag()

a = app.New()
a.Settings().SetTheme(theme.DarkTheme())
Expand Down
7 changes: 3 additions & 4 deletions vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
_ "embed"
"encoding/json"
"fmt"
"gonum.org/v1/plot/plotter"
"math"
Expand All @@ -13,6 +12,8 @@ var dragTable []byte

type DragTable map[string]float64

var dragTableJson = DragTable{}

const timeStep = 1.0 / 60

type vector3 struct {
Expand Down Expand Up @@ -66,9 +67,7 @@ func (v vector3) lerp(vector vector3, t float64) vector3 {

func CalculateForAngle(delta, testAngle, muz float64) (float64, float64, plotter.XYs) {
newPlot := plotter.XYs{}
table := DragTable{}
json.Unmarshal(dragTable, &table)
trueDrag := table[currentGunString]
trueDrag := dragTableJson[currentGunString]

k := -1 * trueDrag * 1
temperature := 15.0
Expand Down

0 comments on commit bb1de29

Please sign in to comment.