Rise
The Vieneo Province
Loading...
Searching...
No Matches
GpwsWindshearSource.h
Go to the documentation of this file.
1#pragma once
4
6{
7 template<class Elevation> Sample SampleGrid(const PlotWeather::Store& source,
8 Vector3 position, Elevation elevation)
9 {
10 const auto& header = source.Header();
11 double u,v; PlotWeather::LocalSample cell; float surface;
12 if (!PlotWeather::Coordinates(position,header.cube,u,v) ||
13 !source.Interpolate(header.cube,u,v,header.requestToken,cell) ||
14 !elevation(header.cube,u,v,surface) || !std::isfinite(surface)) return {};
15 Vector3 up = position;
16 if (!Unit(up)) return {};
17 // Same +Z north and rotation about -up as propulsion's ambient velocity
18 // TO. At the geographic poles bearing is undefined: report unavailable.
19 Vector3 north = Vector3(0,0,1)-up*up.z;
20 if (!Unit(north)) return {};
21 RiseMath::Matrix rotation;
22 const Vector3 axis = -up;
24 Vector3 wind;
25 RiseMath::Vec3TransformNormal(&wind,&north,&rotation);
26 wind *= cell.surfaceWindSpeedMs;
27 return {wind,double(surface)*.001,Finite(wind)};
28 }
29}
bool Interpolate(unsigned cube, double u, double v, uint16_t token, LocalSample &result) const
const SPlotWeatherHeader & Header() const
Sample SampleGrid(const PlotWeather::Store &source, Vector3 position, Elevation elevation)
bool Finite(const Vector3 &v)
bool Unit(Vector3 &v)
bool Coordinates(const RiseMath::Vector3 &position, unsigned cube, double &u, double &v)
Vector3 * Vec3TransformNormal(Vector3 *out, const Vector3 *a, const Matrix *m)
Definition ClientMath.h:107
Matrix * MatrixRotationAxis(Matrix *out, const Vector3 *axis, float angle)
Definition ClientMath.h:129