mirror of
https://codeberg.org/portospaceteam/ground-dashboard.git
synced 2024-11-29 01:56:59 +00:00
23 lines
452 B
Go
23 lines
452 B
Go
package core
|
|
|
|
import "math"
|
|
|
|
func singleFlightDataElement(ds FlightData, accessor func(DataSegment) float64) []float64 {
|
|
data := make([]float64, len(ds.AllSegments()))
|
|
for i, segment := range ds.AllSegments() {
|
|
data[i] = accessor(segment)
|
|
}
|
|
return data
|
|
}
|
|
|
|
func smoothed(alpha float64, xt float64, stm1 float64) float64 {
|
|
return alpha*xt + (1-alpha)*stm1
|
|
}
|
|
|
|
func nanSafe(val float64) float64 {
|
|
if math.IsNaN(val) {
|
|
return 0.0
|
|
}
|
|
return val
|
|
}
|