feat(decart): interp
This commit is contained in:
parent
1bd9143186
commit
19557f3a62
14 changed files with 681 additions and 208 deletions
|
|
@ -26,16 +26,6 @@ func PyMod(a, b float64) float64 {
|
|||
return r
|
||||
}
|
||||
|
||||
// GeoAdd returns y + k*dy with longitude wrapped to [0, 360). Latitude and
|
||||
// altitude accumulate linearly. This is the integrator's state-update step.
|
||||
func GeoAdd(y GeoVec, k float64, dy GeoVec) GeoVec {
|
||||
return GeoVec{
|
||||
Lat: y.Lat + k*dy.Lat,
|
||||
Lng: PyMod(y.Lng+k*dy.Lng, 360),
|
||||
Altitude: y.Altitude + k*dy.Altitude,
|
||||
}
|
||||
}
|
||||
|
||||
// GeoLerp linearly interpolates two geographic states by parameter l in
|
||||
// [0, 1]. Longitude takes the shorter great-circle arc.
|
||||
func GeoLerp(a, b GeoVec, l float64) GeoVec {
|
||||
|
|
@ -65,25 +55,6 @@ func Lerp(a, b, l float64) float64 {
|
|||
return (1-l)*a + l*b
|
||||
}
|
||||
|
||||
// AddGeo returns the component-wise sum a+b without longitude wrapping. Use it
|
||||
// to combine derivative (rate) vectors — rates accumulate linearly, unlike
|
||||
// positions, which wrap via GeoAdd.
|
||||
func AddGeo(a, b GeoVec) GeoVec {
|
||||
return GeoVec{Lat: a.Lat + b.Lat, Lng: a.Lng + b.Lng, Altitude: a.Altitude + b.Altitude}
|
||||
}
|
||||
|
||||
// EarthRadius is the spherical Earth radius (metres) used for horizontal
|
||||
// motion, matching the reference Tawhiri implementation.
|
||||
const EarthRadius = 6371009.0
|
||||
|
||||
// WindToGeoRate converts eastward (u) and northward (v) wind in m/s at the
|
||||
// given latitude (deg) and altitude (m) into the geographic rate in deg/s on a
|
||||
// spherical Earth. The returned dLng diverges near the poles as cos(lat) → 0.
|
||||
func WindToGeoRate(u, v, lat, alt float64) (dLat, dLng float64) {
|
||||
const degPerRad = 180.0 / math.Pi
|
||||
const piOver180 = math.Pi / 180.0
|
||||
r := EarthRadius + alt
|
||||
dLat = degPerRad * v / r
|
||||
dLng = degPerRad * u / (r * math.Cos(lat*piOver180))
|
||||
return dLat, dLng
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue