Skip to content

Commit c30cd4f

Browse files
authored
Merge pull request #46 from johncohn/feature/max-kn-flag
add -max-kn flag to calibrate the legend's wind speed display
2 parents 5f7c342 + 0ac183d commit c30cd4f

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

game.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ type Game struct {
179179
nacaInput string // NACA code being typed in the toolbar field
180180
alphaDeg float64 // angle of attack in degrees
181181
u0 float64
182+
maxDisplayKn float64 // legend's "Wind speed" reading at full slider speed (spdMax) -- see -max-kn
182183
controlDeg float64 // live deflection of the scene's Control object, in degrees
183184
mode fieldMode
184185
paused bool
@@ -359,6 +360,7 @@ func NewGame() *Game {
359360
g := &Game{
360361
alphaDeg: 4,
361362
u0: defaultU,
363+
maxDisplayKn: 25,
362364
glow: true,
363365
showParticles: true,
364366
nacaCode: profiles[0],
@@ -1986,9 +1988,12 @@ func (g *Game) drawLabel(dst *ebiten.Image) {
19861988
ty = barY + barH + 4 + lineH + sectionGap
19871989

19881990
// Lattice units carry no real physical scale (see lbm's package doc), so
1989-
// this maps the same fraction of the solver's stable speed range onto a
1990-
// plausible desktop-exhibit knots range instead of a fabricated SI value.
1991-
knots := 25 * g.u0 / spdMax
1991+
// this maps the same fraction of the solver's stable speed range onto
1992+
// -max-kn instead of a fabricated SI value: full knob/slider speed
1993+
// (spdMax) reads as maxDisplayKn, scaling down proportionally at lower
1994+
// speeds -- set -max-kn to whatever aircraft's real max speed the
1995+
// exhibit is demonstrating.
1996+
knots := g.maxDisplayKn * g.u0 / spdMax
19921997
drawString(dst, fmt.Sprintf("Wind speed: %.0f kn", knots), tx, ty, colValue)
19931998
ty += lineH
19941999
// "deg" not "°": basicfont.Face7x13 (this on-screen text's fixed-width

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func main() {
3131
fullscreen := flag.Bool("fullscreen", false, "start in full screen")
3232
hideControls := flag.Bool("hidecontrols", false, "hide every panel and control, showing only the flow image (kiosk mode)")
3333
substepsFlag := flag.Int("substeps", substeps, "solver steps per displayed frame; lower this on slower hardware to trade physical accuracy for CPU headroom")
34+
maxKn := flag.Float64("max-kn", 25, "wind speed, in knots, the legend's \"Wind speed\" line reads at full slider/knob speed -- calibrate this to whatever real aircraft the exhibit demonstrates")
3435
flag.Parse()
3536

3637
if *substepsFlag < 1 {
@@ -65,6 +66,7 @@ func main() {
6566
g.showLabel = *label
6667
g.demoIdleSec = *demo
6768
g.streamlines = *streamlines
69+
g.maxDisplayKn = *maxKn
6870
if *mode != "" {
6971
fm, ok := parseFieldMode(*mode)
7072
if !ok {

0 commit comments

Comments
 (0)