RCube
Rcube Rest Server calculates sail routes based on Grib files and sailing boat polar files
Loading...
Searching...
No Matches
inline.h File Reference
#include <math.h>
#include <time.h>
Include dependency graph for inline.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static bool isSea (char *isSeaArray, double lat, double lon)
 this file contains small inlines functions to be included in source files
 
static bool isSeaTolerant (char *isSeaArray, double lat, double lon)
 say if point is in sea
 
static double lonCanonize (double lon)
 return lon on ]-180, 180 ] interval
 
static double lonNormalize (double lon, bool anteMeridian)
 if antemeridian -180 < lon < 360.
 
static bool isInZone (double lat, double lon, Zone *zone)
 true if P (lat, lon) is within the zone
 
static double fTwd (double u, double v)
 true wind direction
 
static double fTws (double u, double v)
 true wind speed.
 
static double fTwa (double heading, double twd)
 return TWA between -180 and 180 note : tribord amure if twa < 0
 
static void fAwaAws (double twa, double tws, double sog, double *awa, double *aws)
 return AWA and AWS Apparent Wind Angle and Speed
 
static double interpolate (double x, double x0, double x1, double fx0, double fx1)
 return fx : linear interpolation
 
static double givry (double lat1, double lon1, double lat2, double lon2)
 return givry correction to apply to direct or loxodromic cap to get orthodromic cap

 
static double directCap (double lat1, double lon1, double lat2, double lon2)
 return loxodromic cap from origin to destination
 
static double orthoCap (double lat1, double lon1, double lat2, double lon2)
 return initial orthodromic cap from origin to destination equivalent to : return directCap (lat1, lon1, lat2, lon2) + givry (lat1, lon1, lat2, lon2);
 
static double orthoCap2 (double lat1, double lon1, double lat2, double lon2)
 return initial orthodromic cap from origin to destination, no givry correction
 
static double loxoDist (double lat1, double lon1, double lat2, double lon2)
 return loxodromic distance in nautical miles from origin to destination
 
static double orthoDist (double lat1, double lon1, double lat2, double lon2)
 return orthodromic distance in nautical miles from origin to destination
 
static double orthoDist2 (double lat1, double lon1, double lat2, double lon2)
 return orthodomic distance in nautical miles from origin to destinationi, Haversine formula time consuming
 
static double findPolar (double twa, double w, const PolMat *mat, const PolMat *sailMat, int *sail)
 find in polar boat speed or wave coeff
 
static int binarySearchTwa (const PolMat *mat, double val)
 dichotomic search on column 0 (TWA), using rows [1 .
 
static int binarySearchW (const double *row0, int nCol, double val)
 dichotomic search on row 0 (wind speed), using columns [1 .
 
static double findPolar1 (double twa, double w, const PolMat *mat, const PolMat *sailMat, int *sail)
 find in polar boat speed or wave coeff and sail number if sailMat != NULL
 
static double findPolar2 (double twa, double w, const PolMat *mat, const PolMat *sailMat, int *sail)
 find in polar boat speed or wave coeff and sail number if sailMat != NULL
 
static double maxSpeedInPolarAt (double tws, const PolMat *mat)
 return max speed of boat at tws for all twa
 
static void orthoFindInterPoint (double lat1, double lon1, double lat2, double lon2, double d_nm, double *latR, double *lonR)
 Compute the intermediate point on the great circle from P1 to P2.
 
static bool isDay (double t, long dataDate, long dataTime, double lat, double lon)
 true if day light, false if night
 

Function Documentation

◆ binarySearchTwa()

static int binarySearchTwa ( const PolMat mat,
double  val 
)
inlinestatic

dichotomic search on column 0 (TWA), using rows [1 .

. nLine-1]

Definition at line 211 of file inline.h.

References PolMat::nLine, and PolMat::t.

Referenced by findPolar2().

Here is the caller graph for this function:

◆ binarySearchW()

static int binarySearchW ( const double *  row0,
int  nCol,
double  val 
)
inlinestatic

dichotomic search on row 0 (wind speed), using columns [1 .

. nCol-1]

Definition at line 226 of file inline.h.

Referenced by findPolar1(), findPolar2(), and maxSpeedInPolarAt().

Here is the caller graph for this function:

◆ directCap()

static double directCap ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
inlinestatic

return loxodromic cap from origin to destination

Definition at line 89 of file inline.h.

References DEG_TO_RAD, and RAD_TO_DEG.

Referenced by routing(), and statRoute().

Here is the caller graph for this function:

◆ fAwaAws()

static void fAwaAws ( double  twa,
double  tws,
double  sog,
double *  awa,
double *  aws 
)
inlinestatic

return AWA and AWS Apparent Wind Angle and Speed

Definition at line 70 of file inline.h.

References DEG_TO_RAD, and RAD_TO_DEG.

Referenced by routeToStr().

Here is the caller graph for this function:

◆ findPolar()

static double findPolar ( double  twa,
double  w,
const PolMat mat,
const PolMat sailMat,
int *  sail 
)
inlinestatic

find in polar boat speed or wave coeff

Definition at line 174 of file inline.h.

References interpolate(), PolMat::nCol, PolMat::nLine, and PolMat::t.

Referenced by bestVmg(), bestVmgBack(), buildNextIsochrone(), goalP(), optionManage(), and simpleGoalP().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findPolar1()

static double findPolar1 ( double  twa,
double  w,
const PolMat mat,
const PolMat sailMat,
int *  sail 
)
inlinestatic

find in polar boat speed or wave coeff and sail number if sailMat != NULL

Definition at line 241 of file inline.h.

References binarySearchW(), interpolate(), PolMat::nCol, PolMat::nLine, and PolMat::t.

Referenced by optionManage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findPolar2()

static double findPolar2 ( double  twa,
double  w,
const PolMat mat,
const PolMat sailMat,
int *  sail 
)
inlinestatic

find in polar boat speed or wave coeff and sail number if sailMat != NULL

Definition at line 277 of file inline.h.

References binarySearchTwa(), binarySearchW(), interpolate(), PolMat::nCol, PolMat::nLine, and PolMat::t.

Referenced by optionManage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fTwa()

static double fTwa ( double  heading,
double  twd 
)
inlinestatic

return TWA between -180 and 180 note : tribord amure if twa < 0

Definition at line 64 of file inline.h.

Referenced by buildNextIsochrone(), goalP(), optionManage(), routeToJson(), routeToStr(), and simpleGoalP().

Here is the caller graph for this function:

◆ fTwd()

static double fTwd ( double  u,
double  v 
)
inlinestatic

true wind direction

Definition at line 52 of file inline.h.

References RAD_TO_DEG.

Referenced by findCurrentGrib(), and findWindGrib().

Here is the caller graph for this function:

◆ fTws()

static double fTws ( double  u,
double  v 
)
inlinestatic

true wind speed.

cf Pythagore

Definition at line 58 of file inline.h.

References MS_TO_KN.

Referenced by findCurrentGrib(), findWindGrib(), fPenalty(), fPointLoss(), and fTimeToRecupOnePoint().

Here is the caller graph for this function:

◆ givry()

static double givry ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
inlinestatic

return givry correction to apply to direct or loxodromic cap to get orthodromic cap

Definition at line 84 of file inline.h.

References DEG_TO_RAD.

◆ interpolate()

static double interpolate ( double  x,
double  x0,
double  x1,
double  fx0,
double  fx1 
)
inlinestatic

return fx : linear interpolation

Definition at line 78 of file inline.h.

Referenced by findFlow(), findPolar(), findPolar1(), and findPolar2().

Here is the caller graph for this function:

◆ isDay()

static bool isDay ( double  t,
long  dataDate,
long  dataTime,
double  lat,
double  lon 
)
inlinestatic

true if day light, false if night

  • t : hours since beginning of GRIB (UTC)
  • dataDate : YYYYMMDD (UTC)
  • dataTime : HHMM (UTC) Approximation:
    • local solar hour = GRIB_UTC_time + t + lon/15
    • day if localHour in [6, 18]
    • polar caps: rough month-based rule

Definition at line 421 of file inline.h.

References lonCanonize().

Referenced by buildNextIsochrone(), goalP(), optionManage(), and simpleGoalP().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInZone()

static bool isInZone ( double  lat,
double  lon,
Zone zone 
)
inlinestatic

true if P (lat, lon) is within the zone

Definition at line 47 of file inline.h.

References Zone::latMax, Zone::latMin, Zone::lonLeft, Zone::lonRight, and zone.

Referenced by buildNextIsochrone(), checkParamAndUpdate(), findFlow(), and infoCoordToJson().

Here is the caller graph for this function:

◆ isSea()

static bool isSea ( char *  isSeaArray,
double  lat,
double  lon 
)
inlinestatic

this file contains small inlines functions to be included in source files

say if point is in sea

Definition at line 8 of file inline.h.

Referenced by infoCoordToJson(), optionManage(), segmentOverSea(), and simpleGoal().

Here is the caller graph for this function:

◆ isSeaTolerant()

static bool isSeaTolerant ( char *  isSeaArray,
double  lat,
double  lon 
)
inlinestatic

say if point is in sea

Definition at line 16 of file inline.h.

Referenced by buildNextIsochrone(), checkParamAndUpdate(), goal(), and infoCoordToJson().

Here is the caller graph for this function:

◆ lonCanonize()

static double lonCanonize ( double  lon)
inlinestatic

return lon on ]-180, 180 ] interval

Definition at line 29 of file inline.h.

Referenced by consistentGrib(), isDay(), lonNormalize(), orthoFindInterPoint(), readGribAll(), readGribParameters(), and storeRoute().

Here is the caller graph for this function:

◆ lonNormalize()

static double lonNormalize ( double  lon,
bool  anteMeridian 
)
inlinestatic

if antemeridian -180 < lon < 360.

Normal case : -180 < lon <= 180

Definition at line 40 of file inline.h.

References lonCanonize().

Here is the call graph for this function:

◆ loxoDist()

static double loxoDist ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
inlinestatic

return loxodromic distance in nautical miles from origin to destination

Definition at line 119 of file inline.h.

References DEG_TO_RAD, EARTH_RADIUS, and G_PI.

Referenced by optionManage(), and statRoute().

Here is the caller graph for this function:

◆ maxSpeedInPolarAt()

static double maxSpeedInPolarAt ( double  tws,
const PolMat mat 
)
inlinestatic

return max speed of boat at tws for all twa

Definition at line 308 of file inline.h.

References binarySearchW(), PolMat::nCol, PolMat::nLine, and PolMat::t.

Referenced by buildNextIsochrone(), goalP(), optionManage(), and simpleGoalP().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ orthoCap()

static double orthoCap ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
inlinestatic

return initial orthodromic cap from origin to destination equivalent to : return directCap (lat1, lon1, lat2, lon2) + givry (lat1, lon1, lat2, lon2);

Definition at line 96 of file inline.h.

References DEG_TO_RAD, and RAD_TO_DEG.

Referenced by buildNextIsochrone(), forwardSectorOptimize(), optionManage(), and statRoute().

Here is the caller graph for this function:

◆ orthoCap2()

static double orthoCap2 ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
inlinestatic

return initial orthodromic cap from origin to destination, no givry correction

Definition at line 108 of file inline.h.

References DEG_TO_RAD, and RAD_TO_DEG.

Referenced by optionManage().

Here is the caller graph for this function:

◆ orthoDist()

static double orthoDist ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
inlinestatic

return orthodromic distance in nautical miles from origin to destination

Definition at line 147 of file inline.h.

References CLAMP, DEG_TO_RAD, and RAD_TO_DEG.

Referenced by allCompetitors(), buildNextIsochrone(), checkArrival(), fClosest(), goalP(), logReport(), nearestPort(), optionManage(), orthoFindInterPoint(), routing(), simpleGoalP(), and statRoute().

Here is the caller graph for this function:

◆ orthoDist2()

static double orthoDist2 ( double  lat1,
double  lon1,
double  lat2,
double  lon2 
)
inlinestatic

return orthodomic distance in nautical miles from origin to destinationi, Haversine formula time consuming

Definition at line 161 of file inline.h.

References DEG_TO_RAD, and RAD_TO_DEG.

Referenced by optionManage().

Here is the caller graph for this function:

◆ orthoFindInterPoint()

static void orthoFindInterPoint ( double  lat1,
double  lon1,
double  lat2,
double  lon2,
double  d_nm,
double *  latR,
double *  lonR 
)
inlinestatic

Compute the intermediate point on the great circle from P1 to P2.

This function returns the point Pr (latR, lonR) lying on the orthodromic (great-circle) route from P1 (lat1, lon1) to P2 (lat2, lon2), at a distance d_nm (nautical miles) from P1.

Latitudes and longitudes are in degrees. Distance d_nm is in nautical miles.

The result (latR, lonR) is given in degrees.

Edge cases:

  • If P1 and P2 are (almost) identical, Pr = P1.
  • If d_nm <= 0, Pr = P1.
  • If d_nm >= orthodromic distance P1->P2, Pr = P2.

Definition at line 343 of file inline.h.

References DEG_TO_RAD, lonCanonize(), orthoDist(), and RAD_TO_DEG.

Here is the call graph for this function: