Updates by Christian Mayer.
This commit is contained in:
parent
aacffa37d6
commit
2751545008
27 changed files with 636 additions and 521 deletions
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: FGMicroWeather
|
Called by: FGMicroWeather
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -46,8 +48,9 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include "FGWeatherDefs.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "FGWeatherDefs.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
|
@ -64,31 +67,30 @@ FGAirPressureItem operator-(const FGAirPressureItem& arg);
|
||||||
class FGAirPressureItem
|
class FGAirPressureItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
WeatherPrecition value;
|
WeatherPrecision value;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGAirPressureItem(const WeatherPrecition& v) {value = v;}
|
FGAirPressureItem(const WeatherPrecision v) {value = v;}
|
||||||
FGAirPressureItem() {value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
|
FGAirPressureItem() {value = FG_WEATHER_DEFAULT_AIRPRESSURE;}
|
||||||
|
|
||||||
//WeatherPrecition getValue(WeatherPrecition alt) { return value * pow(1.0 - 0.0065*alt/288.0, 5.255); };
|
WeatherPrecision getValue(const WeatherPrecision& alt) const
|
||||||
|
|
||||||
WeatherPrecition getValue(const WeatherPrecition& alt) const
|
|
||||||
{
|
{
|
||||||
return (WeatherPrecition)((value / 101325.0) *
|
return (WeatherPrecision)((value / 101325.0) *
|
||||||
(
|
(
|
||||||
1.01325e5 + alt * (-1.19459535223623e1 + alt * (5.50461110007561e-4 + alt * (-1.13574703113648e-8 + alt * 8.61601726143988e-14)))
|
1.01325e5 + alt * (-1.19459535223623e1 + alt * (5.50461110007561e-4 + alt * (-1.13574703113648e-8 + alt * 8.61601726143988e-14)))
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
FGAirPressureItem& operator*=(const WeatherPrecition& arg);
|
FGAirPressureItem& operator*=(const WeatherPrecision arg);
|
||||||
FGAirPressureItem& operator+=(const FGAirPressureItem& arg);
|
FGAirPressureItem& operator+=(const FGAirPressureItem& arg);
|
||||||
FGAirPressureItem& operator-=(const FGAirPressureItem& arg);
|
FGAirPressureItem& operator-=(const FGAirPressureItem& arg);
|
||||||
|
|
||||||
friend FGAirPressureItem operator-(const FGAirPressureItem& arg);
|
friend FGAirPressureItem operator-(const FGAirPressureItem& arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FGAirPressureItem& FGAirPressureItem::operator*= (const WeatherPrecition& arg)
|
inline FGAirPressureItem& FGAirPressureItem::operator*= (const WeatherPrecision arg)
|
||||||
{
|
{
|
||||||
value *= arg;
|
value *= arg;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -34,6 +34,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: FGMicroWeather
|
Called by: FGMicroWeather
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -36,6 +36,8 @@ HISTORY
|
||||||
09.10.1999 Christian Mayer changed CloudItem on Durks request
|
09.10.1999 Christian Mayer changed CloudItem on Durks request
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
FUNCTIONAL DESCRIPTION
|
FUNCTIONAL DESCRIPTION
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
Air pressure item that is stored in the micro weather class
|
Cloud item that is stored in the micro weather class
|
||||||
|
|
||||||
HISTORY
|
HISTORY
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
09.10.1999 Christian Mayer changed CloudItem on Durks request
|
09.10.1999 Christian Mayer changed CloudItem on Durks request
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -58,17 +60,17 @@ HISTORY
|
||||||
class FGCloudItem
|
class FGCloudItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
WeatherPrecition thickness;
|
WeatherPrecision thickness;
|
||||||
WeatherPrecition density;
|
WeatherPrecision density;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGCloudItem(const WeatherPrecition& t, const WeatherPrecition& d) {thickness = t; density = d;}
|
FGCloudItem(const WeatherPrecision t, const WeatherPrecision d) {thickness = t; density = d;}
|
||||||
FGCloudItem() {thickness = 0.0; density = 0.0;}
|
FGCloudItem() {thickness = 0.0; density = 0.0;}
|
||||||
|
|
||||||
WeatherPrecition getThickness(void) const { return thickness; }
|
WeatherPrecision getThickness(void) const { return thickness; }
|
||||||
WeatherPrecition getDensity (void) const { return density; }
|
WeatherPrecision getDensity (void) const { return density; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: main program
|
Called by: main program
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -37,6 +37,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -60,23 +62,28 @@ HISTORY
|
||||||
/* | \ \ If p isn't in the triangle the algoritm */
|
/* | \ \ If p isn't in the triangle the algoritm */
|
||||||
/* x1------q------x2 extrapolates it's value */
|
/* x1------q------x2 extrapolates it's value */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
template<class P, class V>
|
template<class V>
|
||||||
V triangle_interpolate(const P& x1, const V& v1, const P& x2, const V& v2, const P& x3, const V& v3, const P& p)
|
V triangle_interpolate(const sgVec2& x1, const V& v1, const sgVec2& x2, const V& v2, const sgVec2& x3, const V& v3, const sgVec2& p)
|
||||||
{
|
{
|
||||||
P q;
|
sgVec2 q;
|
||||||
V q_value;
|
V q_value;
|
||||||
|
|
||||||
q = x1 + (x2 - x1)*( ((x3-x1).x()*(x1-x2).y() - (x1-x2).x()*(x3-x1).y())/((p-x3).x()*(x2-x1).y() - (x2-x1).x()*(p-x3).y()) );
|
//q = x1 + (x2 - x1)*( ((x3-x1).x()*(x1-x2).y() - (x1-x2).x()*(x3-x1).y())/((p-x3).x()*(x2-x1).y() - (x2-x1).x()*(p-x3).y()) );
|
||||||
|
|
||||||
q_value = v1 + (v2 - v1) * (x1.distance3D(q) / x1.distance3D(x2));
|
sgSubVec2 (q, x2, x1);
|
||||||
|
sgScaleVec2(q, (x3[0]-x1[0])*(x1[1]-x2[1]) - (x1[0]-x2[0])*(x3[1]-x1[1]) );
|
||||||
|
sgScaleVec2(q, 1.0 / ( (p [0]-x3[0])*(x2[1]-x1[1]) - (x2[0]-x1[0])*(p [1]-x3[1]) ) );
|
||||||
|
sgAddVec2 (q, x1);
|
||||||
|
|
||||||
|
q_value = v1 + (v2 - v1) * ( sgDistanceVec2(x1, q) / sgDistanceVec2(x1, x2) );
|
||||||
|
|
||||||
return q_value + (v3 - q_value) * (q.distance3D(p) / q.distance3D(x3));
|
return q_value + (v3 - q_value) * ( sgDistanceVec2(q, p) / sgDistanceVec2(q, x3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Constructor and Destructor */
|
/* Constructor and Destructor */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FGGlobalWeatherDatabase::FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus& s)
|
FGGlobalWeatherDatabase::FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus s)
|
||||||
{
|
{
|
||||||
DatabaseStatus = s;
|
DatabaseStatus = s;
|
||||||
}
|
}
|
||||||
|
@ -89,11 +96,11 @@ FGGlobalWeatherDatabase::~FGGlobalWeatherDatabase()
|
||||||
/* Get the physical properties on the specified point p */
|
/* Get the physical properties on the specified point p */
|
||||||
/* do this by interpolating between the 3 closest points */
|
/* do this by interpolating between the 3 closest points */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FGPhysicalProperties FGGlobalWeatherDatabase::get(const Point2D& p) const
|
FGPhysicalProperties FGGlobalWeatherDatabase::get(const sgVec2& p) const
|
||||||
{
|
{
|
||||||
WeatherPrecition distance[3]; //store the 3 closest distances
|
WeatherPrecision distance[3]; //store the 3 closest distances
|
||||||
FGPhysicalProperties2DVectorConstIt iterator[3]; //and the coresponding iterators
|
FGPhysicalProperties2DVectorConstIt iterator[3]; //and the coresponding iterators
|
||||||
WeatherPrecition d;
|
WeatherPrecision d;
|
||||||
|
|
||||||
distance[0] = 9.46e15; //init with a distance that every calculated
|
distance[0] = 9.46e15; //init with a distance that every calculated
|
||||||
distance[1] = 9.46e15; //distance is guranteed to be shorter as
|
distance[1] = 9.46e15; //distance is guranteed to be shorter as
|
||||||
|
@ -101,7 +108,7 @@ FGPhysicalProperties FGGlobalWeatherDatabase::get(const Point2D& p) const
|
||||||
|
|
||||||
for (FGPhysicalProperties2DVectorConstIt it=database.begin(); it!=database.end(); it++)
|
for (FGPhysicalProperties2DVectorConstIt it=database.begin(); it!=database.end(); it++)
|
||||||
{ //go through the whole database
|
{ //go through the whole database
|
||||||
d = it->p.distance2Dsquared(p);
|
d = sgScalarProductVec2(it->p, p);
|
||||||
|
|
||||||
if (d<distance[0])
|
if (d<distance[0])
|
||||||
{
|
{
|
||||||
|
@ -135,7 +142,7 @@ FGPhysicalProperties FGGlobalWeatherDatabase::get(const Point2D& p) const
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* update the database. Since the last call we had dt seconds */
|
/* update the database. Since the last call we had dt seconds */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void FGGlobalWeatherDatabase::update(const WeatherPrecition& dt)
|
void FGGlobalWeatherDatabase::update(const WeatherPrecision dt)
|
||||||
{
|
{
|
||||||
// I've got nothing to update here (yet...)
|
// I've got nothing to update here (yet...)
|
||||||
}
|
}
|
||||||
|
@ -143,11 +150,11 @@ void FGGlobalWeatherDatabase::update(const WeatherPrecition& dt)
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Add a physical property on the specified point p */
|
/* Add a physical property on the specified point p */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void FGGlobalWeatherDatabase::add(const Point2D& p, const FGPhysicalProperties& x)
|
void FGGlobalWeatherDatabase::add(const sgVec2& p, const FGPhysicalProperties& x)
|
||||||
{
|
{
|
||||||
FGPhysicalProperties2D e;
|
FGPhysicalProperties2D e;
|
||||||
|
|
||||||
e.p = p;
|
sgCopyVec2(e.p, p);
|
||||||
|
|
||||||
e.Wind = x.Wind;
|
e.Wind = x.Wind;
|
||||||
e.Turbulence = x.Turbulence;
|
e.Turbulence = x.Turbulence;
|
||||||
|
@ -167,11 +174,11 @@ void FGGlobalWeatherDatabase::add(const Point2D& p, const FGPhysicalProperties&
|
||||||
/* Change the closest physical property to p. If p is further away than */
|
/* Change the closest physical property to p. If p is further away than */
|
||||||
/* tolerance I'm returning false otherwise true */
|
/* tolerance I'm returning false otherwise true */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
bool FGGlobalWeatherDatabase::change(const FGPhysicalProperties2D& p, const WeatherPrecition& tolerance)
|
bool FGGlobalWeatherDatabase::change(const FGPhysicalProperties2D& p, const WeatherPrecision tolerance)
|
||||||
{
|
{
|
||||||
for (FGPhysicalProperties2DVectorIt it = database.begin(); it != database.end(); it++)
|
for (FGPhysicalProperties2DVectorIt it = database.begin(); it != database.end(); it++)
|
||||||
{
|
{
|
||||||
if (it->p.distance3Dsquared(p.p) < (tolerance*tolerance))
|
if (sgScalarProductVec2(it->p, p.p) < (tolerance*tolerance))
|
||||||
{ //assume that's my point
|
{ //assume that's my point
|
||||||
(*it) = p;
|
(*it) = p;
|
||||||
return true;
|
return true;
|
||||||
|
@ -185,25 +192,25 @@ bool FGGlobalWeatherDatabase::change(const FGPhysicalProperties2D& p, const Weat
|
||||||
/* Get all, but at least min, stored point in the circle around p with the */
|
/* Get all, but at least min, stored point in the circle around p with the */
|
||||||
/* radius r */
|
/* radius r */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FGPhysicalProperties2DVector FGGlobalWeatherDatabase::getAll(const Point2D& p, const WeatherPrecition& r, const unsigned int& min)
|
FGPhysicalProperties2DVector FGGlobalWeatherDatabase::getAll(const sgVec2& p, const WeatherPrecision r, const unsigned int min)
|
||||||
{
|
{
|
||||||
FGPhysicalProperties2DVector ret_list;
|
FGPhysicalProperties2DVector ret_list;
|
||||||
|
|
||||||
if ((DatabaseStatus == FGGlobalWeatherDatabase_only_static)
|
if ( (DatabaseStatus == FGGlobalWeatherDatabase_only_static)
|
||||||
||(DatabaseStatus == FGGlobalWeatherDatabase_working) )
|
||(DatabaseStatus == FGGlobalWeatherDatabase_working ) )
|
||||||
{ //doest it make sense?
|
{ //doest it make sense?
|
||||||
|
|
||||||
FGPhysicalProperties2DVectorIt *it; //store the closest entries
|
FGPhysicalProperties2DVectorIt *it; //store the closest entries
|
||||||
WeatherPrecition *d;
|
WeatherPrecision *d;
|
||||||
unsigned int act_it = 0;
|
unsigned int act_it = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
it = new FGPhysicalProperties2DVectorIt[min+1];
|
it = new FGPhysicalProperties2DVectorIt[min+1];
|
||||||
d = new WeatherPrecition[min+1];
|
d = new WeatherPrecision[min+1];
|
||||||
|
|
||||||
for (it[0]=database.begin(); it[act_it]!=database.end(); it[act_it]++)
|
for (it[0]=database.begin(); it[act_it]!=database.end(); it[act_it]++)
|
||||||
{ //go through the whole database
|
{ //go through the whole database
|
||||||
d[act_it] = it[act_it]->p.distance2Dsquared(p);
|
d[act_it] = sgScalarProductVec2(it[act_it]->p, p);
|
||||||
|
|
||||||
if (r >= d[act_it])
|
if (r >= d[act_it])
|
||||||
{ //add it
|
{ //add it
|
||||||
|
@ -213,7 +220,7 @@ FGPhysicalProperties2DVector FGGlobalWeatherDatabase::getAll(const Point2D& p, c
|
||||||
{
|
{
|
||||||
if (act_it>0)
|
if (act_it>0)
|
||||||
{ //figure out if this distance belongs to the closest ones
|
{ //figure out if this distance belongs to the closest ones
|
||||||
WeatherPrecition dummy;
|
WeatherPrecision dummy;
|
||||||
FGPhysicalProperties2DVectorIt dummyIt;
|
FGPhysicalProperties2DVectorIt dummyIt;
|
||||||
|
|
||||||
for (i = act_it++; i >= 0;)
|
for (i = act_it++; i >= 0;)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -37,6 +37,8 @@ HISTORY
|
||||||
30.06.1999 Christian Mayer STL portability
|
30.06.1999 Christian Mayer STL portability
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -48,18 +50,27 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include "FGPhysicalProperties.h"
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "FGPhysicalProperty.h"
|
# include <config.h>
|
||||||
#include "sg.h"
|
#endif
|
||||||
|
|
||||||
#include <Include/compiler.h>
|
#include <Include/compiler.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include STL_IOSTREAM
|
#include STL_IOSTREAM
|
||||||
|
|
||||||
|
#include <sg.h>
|
||||||
|
|
||||||
|
#include "FGPhysicalProperties.h"
|
||||||
|
#include "FGPhysicalProperty.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FG_USING_STD(vector);
|
FG_USING_STD(vector);
|
||||||
|
#ifndef FG_HAVE_NATIVE_SGI_COMPILERS
|
||||||
FG_USING_STD(iostream);
|
FG_USING_STD(iostream);
|
||||||
|
#endif
|
||||||
FG_USING_NAMESPACE(std);
|
FG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
enum FGGlobalWeatherDatabaseStatus {
|
enum FGGlobalWeatherDatabaseStatus {
|
||||||
|
@ -86,50 +97,63 @@ public:
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Constructor and Destructor */
|
/* Constructor and Destructor */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus& s = FGGlobalWeatherDatabase_not_used);
|
FGGlobalWeatherDatabase(const FGGlobalWeatherDatabaseStatus s = FGGlobalWeatherDatabase_not_used);
|
||||||
~FGGlobalWeatherDatabase();
|
~FGGlobalWeatherDatabase();
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Get the physical properties on the specified point p */
|
/* Get the physical properties on the specified point p */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
FGPhysicalProperties get(const Point2D& p) const;
|
FGPhysicalProperties get(const sgVec2& p) const;
|
||||||
FGPhysicalProperties get(const sgVec2& p) const {return get(Point2D(p[0], p[1]));}
|
FGPhysicalProperty get(const sgVec3& p) const
|
||||||
inline FGPhysicalProperty get(const Point3D& p) const {return FGPhysicalProperty(get(Point2D(p)), p.elev());}
|
{
|
||||||
inline FGPhysicalProperty get(const sgVec3& p) const {return FGPhysicalProperty(get(Point2D(p[0], p[1])), p[3]);}
|
sgVec2 temp;
|
||||||
|
sgSetVec2( temp, p[0], p[1] );
|
||||||
|
|
||||||
|
return FGPhysicalProperty( get(temp), p[3] );
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* update the database. Since the last call we had dt seconds */
|
/* update the database. Since the last call we had dt seconds */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void update(const WeatherPrecition& dt);
|
void update(const WeatherPrecision dt);
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Add a physical property on the specified point p */
|
/* Add a physical property on the specified point p */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void add(const Point2D& p, const FGPhysicalProperties& x);
|
void add(const sgVec2& p, const FGPhysicalProperties& x);
|
||||||
inline void add(const FGPhysicalProperties2D& x) {database.push_back(x);}
|
void add(const FGPhysicalProperties2D& x)
|
||||||
|
{
|
||||||
|
database.push_back(x);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Change the closest physical property to p. If p is further away than */
|
/* Change the closest physical property to p. If p is further away than */
|
||||||
/* tolerance I'm returning false otherwise true */
|
/* tolerance I'm returning false otherwise true */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
bool change(const FGPhysicalProperties2D& p, const WeatherPrecition& tolerance = 0.0000001);
|
bool change(const FGPhysicalProperties2D& p, const WeatherPrecision tolerance = 0.0000001);
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Get all stored points in the circle around p with the radius r, but */
|
/* Get all stored points in the circle around p with the radius r, but */
|
||||||
/* at least min points. */
|
/* at least min points. */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
FGPhysicalProperties2DVector getAll(const Point2D& p, const WeatherPrecition& r, const unsigned int& min = 0);
|
FGPhysicalProperties2DVector getAll(const sgVec2& p, const WeatherPrecision r, const unsigned int min = 0);
|
||||||
|
FGPhysicalProperties2DVector getAll(const sgVec3& p, const WeatherPrecision r, const unsigned int min = 0)
|
||||||
|
{
|
||||||
|
sgVec2 temp;
|
||||||
|
sgSetVec2(temp, p[0], p[1]);
|
||||||
|
|
||||||
|
return getAll(temp, r, min);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* get/set the operating status of the database */
|
/* get/set the operating status of the database */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
FGGlobalWeatherDatabaseStatus getDatabaseStatus(void) const { return DatabaseStatus; }
|
FGGlobalWeatherDatabaseStatus getDatabaseStatus(void) const { return DatabaseStatus; }
|
||||||
void setDatabaseStatus(const FGGlobalWeatherDatabaseStatus& s) { DatabaseStatus = s; }
|
void setDatabaseStatus(const FGGlobalWeatherDatabaseStatus& s) { DatabaseStatus = s; }
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Dump the whole database */
|
/* Dump the whole database */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
//friend istream& operator>> ( istream&, Point3D& );
|
|
||||||
friend ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
|
friend ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -146,4 +170,4 @@ inline ostream& operator<< ( ostream& out, const FGGlobalWeatherDatabase& p )
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#endif /*FGGlobalWeatherDatabase_H*/
|
#endif /*FGGlobalWeatherDatabase_H*/
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: main program
|
Called by: main program
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -36,17 +36,21 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include "FGLocalWeatherDatabase.h"
|
#include <Include/compiler.h>
|
||||||
#include "FGVoronoi.h"
|
#include <Include/fg_constants.h>
|
||||||
#include "fg_constants.h"
|
|
||||||
|
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Include/fg_constants.h>
|
|
||||||
|
#include "FGLocalWeatherDatabase.h"
|
||||||
|
#include "FGVoronoi.h"
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/********************************** CODE ************************************/
|
/********************************** CODE ************************************/
|
||||||
|
@ -55,7 +59,7 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* return the index (better: ID) of the area with point p */
|
/* return the index (better: ID) of the area with point p */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
unsigned int FGLocalWeatherDatabase::AreaWith(const Point2D& p) const
|
unsigned int FGLocalWeatherDatabase::AreaWith(const sgVec2& p) const
|
||||||
{
|
{
|
||||||
|
|
||||||
for (FGMicroWeatherList::size_type i = 0; i != WeatherAreas.size(); i++)
|
for (FGMicroWeatherList::size_type i = 0; i != WeatherAreas.size(); i++)
|
||||||
|
@ -74,7 +78,7 @@ void FGLocalWeatherDatabase::tileLocalWeather(const FGPhysicalProperties2DVector
|
||||||
{
|
{
|
||||||
FGVoronoiInputList input;
|
FGVoronoiInputList input;
|
||||||
|
|
||||||
for (FGPhysicalProperties2DVector::const_iterator it1 = EntryList.begin(); it1 != EntryList.end(); it1++)
|
for (FGPhysicalProperties2DVectorConstIt it1 = EntryList.begin(); it1 != EntryList.end(); it1++)
|
||||||
input.push_back(FGVoronoiInput(it1->p, *it1));
|
input.push_back(FGVoronoiInput(it1->p, *it1));
|
||||||
|
|
||||||
FGVoronoiOutputList output = Voronoiate(input);
|
FGVoronoiOutputList output = Voronoiate(input);
|
||||||
|
@ -89,7 +93,7 @@ void FGLocalWeatherDatabase::tileLocalWeather(const FGPhysicalProperties2DVector
|
||||||
FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0;
|
FGLocalWeatherDatabase* FGLocalWeatherDatabase::theFGLocalWeatherDatabase = 0;
|
||||||
FGLocalWeatherDatabase *WeatherDatabase;
|
FGLocalWeatherDatabase *WeatherDatabase;
|
||||||
|
|
||||||
FGLocalWeatherDatabase::FGLocalWeatherDatabase(const Point3D& posititon, const WeatherPrecition& visibility, const DatabaseWorkingType& type)
|
FGLocalWeatherDatabase::FGLocalWeatherDatabase(const sgVec3& posititon, const WeatherPrecision visibility, const DatabaseWorkingType type)
|
||||||
{
|
{
|
||||||
cerr << "Initializing FGLocalWeatherDatabase\n";
|
cerr << "Initializing FGLocalWeatherDatabase\n";
|
||||||
cerr << "-----------------------------------\n";
|
cerr << "-----------------------------------\n";
|
||||||
|
@ -102,10 +106,10 @@ FGLocalWeatherDatabase::FGLocalWeatherDatabase(const Point3D& posititon, const W
|
||||||
}
|
}
|
||||||
|
|
||||||
setWeatherVisibility(visibility);
|
setWeatherVisibility(visibility);
|
||||||
//WeatherVisibility = visibility;
|
|
||||||
DatabaseStatus = type;
|
DatabaseStatus = type;
|
||||||
global = 0; //just get sure...
|
global = 0; //just get sure...
|
||||||
last_known_position = posititon;
|
sgCopyVec3(last_known_position, posititon);
|
||||||
|
|
||||||
|
|
||||||
theFGLocalWeatherDatabase = this;
|
theFGLocalWeatherDatabase = this;
|
||||||
|
@ -127,7 +131,7 @@ FGLocalWeatherDatabase::FGLocalWeatherDatabase(const Point3D& posititon, const W
|
||||||
case manual:
|
case manual:
|
||||||
case default_mode:
|
case default_mode:
|
||||||
{
|
{
|
||||||
vector<Point2D> emptyList;
|
vector<sgVec2Wrap> emptyList;
|
||||||
WeatherAreas.push_back(FGMicroWeather(FGPhysicalProperties2D(), emptyList)); //in these cases I've only got one tile
|
WeatherAreas.push_back(FGMicroWeather(FGPhysicalProperties2D(), emptyList)); //in these cases I've only got one tile
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -152,7 +156,7 @@ FGLocalWeatherDatabase::~FGLocalWeatherDatabase()
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* reset the whole database */
|
/* reset the whole database */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void FGLocalWeatherDatabase::reset(const DatabaseWorkingType& type)
|
void FGLocalWeatherDatabase::reset(const DatabaseWorkingType type)
|
||||||
{
|
{
|
||||||
//delete global database if necessary
|
//delete global database if necessary
|
||||||
if ((DatabaseStatus == use_global) && (type != use_global))
|
if ((DatabaseStatus == use_global) && (type != use_global))
|
||||||
|
@ -169,23 +173,23 @@ void FGLocalWeatherDatabase::reset(const DatabaseWorkingType& type)
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* update the database. Since the last call we had dt seconds */
|
/* update the database. Since the last call we had dt seconds */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void FGLocalWeatherDatabase::update(const WeatherPrecition& dt)
|
void FGLocalWeatherDatabase::update(const WeatherPrecision dt)
|
||||||
{
|
{
|
||||||
if (DatabaseStatus==use_global)
|
if (DatabaseStatus==use_global)
|
||||||
global->update(dt);
|
global->update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::update(const Point3D& p) //position has changed
|
void FGLocalWeatherDatabase::update(const sgVec3& p) //position has changed
|
||||||
{
|
{
|
||||||
last_known_position = p;
|
sgCopyVec3(last_known_position, p);
|
||||||
//cerr << "****\nupdate inside\n";
|
//cerr << "****\nupdate inside\n";
|
||||||
//cerr << "Parameter: " << p << "\n";
|
//cerr << "Parameter: " << p << "\n";
|
||||||
//cerr << "****\n";
|
//cerr << "****\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::update(const Point3D& p, const WeatherPrecition& dt) //time and/or position has changed
|
void FGLocalWeatherDatabase::update(const sgVec3& p, const WeatherPrecision dt) //time and/or position has changed
|
||||||
{
|
{
|
||||||
last_known_position = p;
|
sgCopyVec3(last_known_position, p);
|
||||||
|
|
||||||
if (DatabaseStatus==use_global)
|
if (DatabaseStatus==use_global)
|
||||||
global->update(dt);
|
global->update(dt);
|
||||||
|
@ -194,29 +198,19 @@ void FGLocalWeatherDatabase::update(const Point3D& p, const WeatherPrecition& dt
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Get the physical properties on the specified point p out of the database */
|
/* Get the physical properties on the specified point p out of the database */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FGPhysicalProperty FGLocalWeatherDatabase::get(const Point3D& p) const
|
FGPhysicalProperty FGLocalWeatherDatabase::get(const sgVec3& p) const
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
return WeatherAreas[a-1].get(p.elev());
|
return WeatherAreas[a-1].get(p[3]);
|
||||||
else //point is outside => ask GlobalWeatherDatabase
|
else //point is outside => ask GlobalWeatherDatabase
|
||||||
return global->get(p);
|
return global->get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
FGPhysicalProperty FGLocalWeatherDatabase::get(const sgVec3& p) const
|
|
||||||
{
|
|
||||||
Point3D temp(p[0], p[1], p[2]);
|
|
||||||
|
|
||||||
unsigned int a = AreaWith(temp);
|
|
||||||
if (a != 0)
|
|
||||||
return WeatherAreas[a-1].get(temp.elev());
|
|
||||||
else //point is outside => ask GlobalWeatherDatabase
|
|
||||||
return global->get(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
FGPhysicalProperties FGLocalWeatherDatabase::get(const sgVec2& p) const
|
FGPhysicalProperties FGLocalWeatherDatabase::get(const sgVec2& p) const
|
||||||
{
|
{
|
||||||
Point3D temp(p[0], p[1], 0.0);
|
sgVec3 temp;
|
||||||
|
sgSetVec3(temp, p[0], p[1], 0.0);
|
||||||
|
|
||||||
unsigned int a = AreaWith(temp);
|
unsigned int a = AreaWith(temp);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
|
@ -225,12 +219,12 @@ FGPhysicalProperties FGLocalWeatherDatabase::get(const sgVec2& p) const
|
||||||
return global->get(p);
|
return global->get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
WeatherPrecition FGLocalWeatherDatabase::getAirDensity(const Point3D& p) const
|
WeatherPrecision FGLocalWeatherDatabase::getAirDensity(const sgVec3& p) const
|
||||||
{
|
{
|
||||||
FGPhysicalProperty dummy;
|
FGPhysicalProperty dummy;
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
dummy = WeatherAreas[a-1].get(p.elev());
|
dummy = WeatherAreas[a-1].get(p[3]);
|
||||||
else //point is outside => ask GlobalWeatherDatabase
|
else //point is outside => ask GlobalWeatherDatabase
|
||||||
dummy = global->get(p);
|
dummy = global->get(p);
|
||||||
|
|
||||||
|
@ -239,82 +233,66 @@ WeatherPrecition FGLocalWeatherDatabase::getAirDensity(const Point3D& p) const
|
||||||
(dummy.Temperature*FG_WEATHER_DEFAULT_AIRPRESSURE);
|
(dummy.Temperature*FG_WEATHER_DEFAULT_AIRPRESSURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
WeatherPrecition FGLocalWeatherDatabase::getAirDensity(const sgVec3& p) const
|
|
||||||
{
|
|
||||||
Point3D temp(p[0], p[1], p[2]);
|
|
||||||
|
|
||||||
FGPhysicalProperty dummy;
|
|
||||||
unsigned int a = AreaWith(temp);
|
|
||||||
if (a != 0)
|
|
||||||
dummy = WeatherAreas[a-1].get(temp.elev());
|
|
||||||
else //point is outside => ask GlobalWeatherDatabase
|
|
||||||
dummy = global->get(temp);
|
|
||||||
|
|
||||||
return
|
|
||||||
(dummy.AirPressure*FG_WEATHER_DEFAULT_AIRDENSITY*FG_WEATHER_DEFAULT_TEMPERATURE) /
|
|
||||||
(dummy.Temperature*FG_WEATHER_DEFAULT_AIRPRESSURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Add a weather feature at the point p and surrounding area */
|
/* Add a weather feature at the point p and surrounding area */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void FGLocalWeatherDatabase::addWind(const WeatherPrecition alt, const Point3D& x, const Point2D& p)
|
void FGLocalWeatherDatabase::addWind(const WeatherPrecision alt, const sgVec3& x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].addWind(alt, x);
|
WeatherAreas[a-1].addWind(alt, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::addTurbulence(const WeatherPrecition alt, const Point3D& x, const Point2D& p)
|
void FGLocalWeatherDatabase::addTurbulence(const WeatherPrecision alt, const sgVec3& x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].addTurbulence(alt, x);
|
WeatherAreas[a-1].addTurbulence(alt, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::addTemperature(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p)
|
void FGLocalWeatherDatabase::addTemperature(const WeatherPrecision alt, const WeatherPrecision x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].addTemperature(alt, x);
|
WeatherAreas[a-1].addTemperature(alt, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::addAirPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p)
|
void FGLocalWeatherDatabase::addAirPressure(const WeatherPrecision alt, const WeatherPrecision x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].addAirPressure(alt, x);
|
WeatherAreas[a-1].addAirPressure(alt, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p)
|
void FGLocalWeatherDatabase::addVaporPressure(const WeatherPrecision alt, const WeatherPrecision x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].addVaporPressure(alt, x);
|
WeatherAreas[a-1].addVaporPressure(alt, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::addCloud(const WeatherPrecition alt, const FGCloudItem& x, const Point2D& p)
|
void FGLocalWeatherDatabase::addCloud(const WeatherPrecision alt, const FGCloudItem& x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].addCloud(alt, x);
|
WeatherAreas[a-1].addCloud(alt, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::setSnowRainIntensity(const WeatherPrecition& x, const Point2D& p)
|
void FGLocalWeatherDatabase::setSnowRainIntensity(const WeatherPrecision x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].setSnowRainIntensity(x);
|
WeatherAreas[a-1].setSnowRainIntensity(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::setSnowRainType(const SnowRainType& x, const Point2D& p)
|
void FGLocalWeatherDatabase::setSnowRainType(const SnowRainType x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
WeatherAreas[a-1].setSnowRainType(x);
|
WeatherAreas[a-1].setSnowRainType(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGLocalWeatherDatabase::setLightningProbability(const WeatherPrecition& x, const Point2D& p)
|
void FGLocalWeatherDatabase::setLightningProbability(const WeatherPrecision x, const sgVec2& p)
|
||||||
{
|
{
|
||||||
unsigned int a = AreaWith(p);
|
unsigned int a = AreaWith(p);
|
||||||
if (a != 0)
|
if (a != 0)
|
||||||
|
@ -370,9 +348,12 @@ void FGLocalWeatherDatabase::setProperties(const FGPhysicalProperties2D& x)
|
||||||
void fgUpdateWeatherDatabase(void)
|
void fgUpdateWeatherDatabase(void)
|
||||||
{
|
{
|
||||||
//cerr << "FGLocalWeatherDatabase::update()\n";
|
//cerr << "FGLocalWeatherDatabase::update()\n";
|
||||||
WeatherDatabase->update( Point3D(
|
sgVec3 position;
|
||||||
|
sgSetVec3(position,
|
||||||
current_aircraft.fdm_state->get_Latitude(),
|
current_aircraft.fdm_state->get_Latitude(),
|
||||||
current_aircraft.fdm_state->get_Longitude(),
|
current_aircraft.fdm_state->get_Longitude(),
|
||||||
current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER) );
|
current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER);
|
||||||
|
|
||||||
|
WeatherDatabase->update( position );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -36,6 +36,8 @@ HISTORY
|
||||||
30.06.1999 Christian Mayer STL portability
|
30.06.1999 Christian Mayer STL portability
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -56,6 +58,7 @@ HISTORY
|
||||||
#include <XGL/xgl.h>
|
#include <XGL/xgl.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "sg.h"
|
#include "sg.h"
|
||||||
|
|
||||||
#include "FGPhysicalProperties.h"
|
#include "FGPhysicalProperties.h"
|
||||||
|
@ -79,10 +82,10 @@ private:
|
||||||
protected:
|
protected:
|
||||||
FGGlobalWeatherDatabase *global; //point to the global database
|
FGGlobalWeatherDatabase *global; //point to the global database
|
||||||
|
|
||||||
typedef vector<FGMicroWeather> FGMicroWeatherList;
|
typedef vector<FGMicroWeather> FGMicroWeatherList;
|
||||||
typedef FGMicroWeatherList::iterator FGMicroWeatherListIt;
|
typedef FGMicroWeatherList::iterator FGMicroWeatherListIt;
|
||||||
|
|
||||||
typedef vector<Point2D> pointVector;
|
typedef vector<sgVec2> pointVector;
|
||||||
typedef vector<pointVector> tileVector;
|
typedef vector<pointVector> tileVector;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
@ -92,9 +95,22 @@ protected:
|
||||||
|
|
||||||
FGMicroWeatherList WeatherAreas;
|
FGMicroWeatherList WeatherAreas;
|
||||||
|
|
||||||
WeatherPrecition WeatherVisibility; //how far do I need to simulate the
|
WeatherPrecision WeatherVisibility; //how far do I need to simulate the
|
||||||
//local weather? Unit: metres
|
//local weather? Unit: metres
|
||||||
Point3D last_known_position;
|
sgVec3 last_known_position;
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
/* return the index of the area with point p */
|
||||||
|
/************************************************************************/
|
||||||
|
unsigned int AreaWith(const sgVec2& p) const;
|
||||||
|
unsigned int AreaWith(const sgVec3& p) const
|
||||||
|
{
|
||||||
|
sgVec2 temp;
|
||||||
|
sgSetVec2(temp, p[0], p[1]);
|
||||||
|
|
||||||
|
return AreaWith(temp);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static FGLocalWeatherDatabase *theFGLocalWeatherDatabase;
|
static FGLocalWeatherDatabase *theFGLocalWeatherDatabase;
|
||||||
|
@ -108,60 +124,65 @@ public:
|
||||||
default_mode //use only default values
|
default_mode //use only default values
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
|
||||||
DatabaseWorkingType DatabaseStatus;
|
DatabaseWorkingType DatabaseStatus;
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* return the index of the area with point p */
|
|
||||||
/************************************************************************/
|
|
||||||
unsigned int AreaWith(const Point2D& p) const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Constructor and Destructor */
|
/* Constructor and Destructor */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
FGLocalWeatherDatabase(
|
FGLocalWeatherDatabase(
|
||||||
const Point3D& posititon,
|
const sgVec3& posititon,
|
||||||
const WeatherPrecition& visibility = DEFAULT_WEATHER_VISIBILIY,
|
const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILIY,
|
||||||
const DatabaseWorkingType& type = PREFERED_WORKING_TYPE);
|
const DatabaseWorkingType type = PREFERED_WORKING_TYPE);
|
||||||
|
|
||||||
|
FGLocalWeatherDatabase(
|
||||||
|
const WeatherPrecision posititon_lat,
|
||||||
|
const WeatherPrecision posititon_lon,
|
||||||
|
const WeatherPrecision posititon_alt,
|
||||||
|
const WeatherPrecision visibility = DEFAULT_WEATHER_VISIBILIY,
|
||||||
|
const DatabaseWorkingType type = PREFERED_WORKING_TYPE)
|
||||||
|
{
|
||||||
|
sgVec3 position;
|
||||||
|
sgSetVec3( position, posititon_lat, posititon_lon, posititon_alt );
|
||||||
|
|
||||||
|
FGLocalWeatherDatabase( position, visibility, type );
|
||||||
|
}
|
||||||
|
|
||||||
~FGLocalWeatherDatabase();
|
~FGLocalWeatherDatabase();
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* reset the whole database */
|
/* reset the whole database */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void reset(const DatabaseWorkingType& type = PREFERED_WORKING_TYPE);
|
void reset(const DatabaseWorkingType type = PREFERED_WORKING_TYPE);
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* update the database. Since the last call we had dt seconds */
|
/* update the database. Since the last call we had dt seconds */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void update(const WeatherPrecition& dt); //time has changed
|
void update(const WeatherPrecision dt); //time has changed
|
||||||
void update(const Point3D& p); //position has changed
|
void update(const sgVec3& p); //position has changed
|
||||||
void update(const Point3D& p, const WeatherPrecition& dt); //time and/or position has changed
|
void update(const sgVec3& p, const WeatherPrecision dt); //time and/or position has changed
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Get the physical properties on the specified point p */
|
/* Get the physical properties on the specified point p */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
FGPhysicalProperty get(const Point3D& p) const;
|
|
||||||
FGPhysicalProperty get(const sgVec3& p) const;
|
|
||||||
FGPhysicalProperties get(const sgVec2& p) const;
|
FGPhysicalProperties get(const sgVec2& p) const;
|
||||||
|
FGPhysicalProperty get(const sgVec3& p) const;
|
||||||
|
|
||||||
WeatherPrecition getAirDensity(const Point3D& p) const;
|
WeatherPrecision getAirDensity(const sgVec3& p) const;
|
||||||
WeatherPrecition getAirDensity(const sgVec3& p) const;
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Add a weather feature at the point p and surrounding area */
|
/* Add a weather feature at the point p and surrounding area */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
void addWind(const WeatherPrecition alt, const Point3D& x, const Point2D& p);
|
void addWind (const WeatherPrecision alt, const sgVec3& x, const sgVec2& p);
|
||||||
void addTurbulence(const WeatherPrecition alt, const Point3D& x, const Point2D& p);
|
void addTurbulence (const WeatherPrecision alt, const sgVec3& x, const sgVec2& p);
|
||||||
void addTemperature(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p);
|
void addTemperature (const WeatherPrecision alt, const WeatherPrecision x, const sgVec2& p);
|
||||||
void addAirPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p);
|
void addAirPressure (const WeatherPrecision alt, const WeatherPrecision x, const sgVec2& p);
|
||||||
void addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x, const Point2D& p);
|
void addVaporPressure(const WeatherPrecision alt, const WeatherPrecision x, const sgVec2& p);
|
||||||
void addCloud(const WeatherPrecition alt, const FGCloudItem& x, const Point2D& p);
|
void addCloud (const WeatherPrecision alt, const FGCloudItem& x, const sgVec2& p);
|
||||||
|
|
||||||
void setSnowRainIntensity(const WeatherPrecition& x, const Point2D& p);
|
void setSnowRainIntensity (const WeatherPrecision x, const sgVec2& p);
|
||||||
void setSnowRainType(const SnowRainType& x, const Point2D& p);
|
void setSnowRainType (const SnowRainType x, const sgVec2& p);
|
||||||
void setLightningProbability(const WeatherPrecition& x, const Point2D& p);
|
void setLightningProbability(const WeatherPrecision x, const sgVec2& p);
|
||||||
|
|
||||||
void addProperties(const FGPhysicalProperties2D& x); //add a property
|
void addProperties(const FGPhysicalProperties2D& x); //add a property
|
||||||
void setProperties(const FGPhysicalProperties2D& x); //change a property
|
void setProperties(const FGPhysicalProperties2D& x); //change a property
|
||||||
|
@ -169,8 +190,8 @@ public:
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* get/set weather visibility */
|
/* get/set weather visibility */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void setWeatherVisibility(const WeatherPrecition& visibility);
|
void setWeatherVisibility(const WeatherPrecision visibility);
|
||||||
WeatherPrecition getWeatherVisibility(void) const;
|
WeatherPrecision getWeatherVisibility(void) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FGLocalWeatherDatabase *WeatherDatabase;
|
extern FGLocalWeatherDatabase *WeatherDatabase;
|
||||||
|
@ -179,7 +200,7 @@ void fgUpdateWeatherDatabase(void);
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* get/set weather visibility */
|
/* get/set weather visibility */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecition& visibility)
|
void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecision visibility)
|
||||||
{
|
{
|
||||||
if (visibility >= MINIMUM_WEATHER_VISIBILIY)
|
if (visibility >= MINIMUM_WEATHER_VISIBILIY)
|
||||||
WeatherVisibility = visibility;
|
WeatherVisibility = visibility;
|
||||||
|
@ -210,7 +231,7 @@ void inline FGLocalWeatherDatabase::setWeatherVisibility(const WeatherPrecition&
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WeatherPrecition inline FGLocalWeatherDatabase::getWeatherVisibility(void) const
|
WeatherPrecision inline FGLocalWeatherDatabase::getWeatherVisibility(void) const
|
||||||
{
|
{
|
||||||
//cerr << "FGLocalWeatherDatabase::getWeatherVisibility() = " << WeatherVisibility << "\n";
|
//cerr << "FGLocalWeatherDatabase::getWeatherVisibility() = " << WeatherVisibility << "\n";
|
||||||
return WeatherVisibility;
|
return WeatherVisibility;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: FGLocalWeatherDatabase
|
Called by: FGLocalWeatherDatabase
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,13 +35,17 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
#include <Include/compiler.h>
|
||||||
|
#include <Include/fg_constants.h>
|
||||||
|
|
||||||
#include "FGMicroWeather.h"
|
#include "FGMicroWeather.h"
|
||||||
#include "fg_constants.h"
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/********************************** CODE ************************************/
|
/********************************** CODE ************************************/
|
||||||
|
@ -60,48 +64,48 @@ FGMicroWeather::~FGMicroWeather()
|
||||||
/* Add the features to the micro weather */
|
/* Add the features to the micro weather */
|
||||||
/* return succss */
|
/* return succss */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
void FGMicroWeather::addWind(const WeatherPrecition alt, const Point3D& x)
|
void FGMicroWeather::addWind(const WeatherPrecision alt, const FGWindItem& x)
|
||||||
{
|
{
|
||||||
StoredWeather.Wind[alt] = x;
|
StoredWeather.Wind[alt] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::addTurbulence(const WeatherPrecition alt, const Point3D& x)
|
void FGMicroWeather::addTurbulence(const WeatherPrecision alt, const FGTurbulenceItem& x)
|
||||||
{
|
{
|
||||||
StoredWeather.Turbulence[alt] = x;
|
StoredWeather.Turbulence[alt] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::addTemperature(const WeatherPrecition alt, const WeatherPrecition x)
|
void FGMicroWeather::addTemperature(const WeatherPrecision alt, const WeatherPrecision x)
|
||||||
{
|
{
|
||||||
StoredWeather.Temperature[alt] = x;
|
StoredWeather.Temperature[alt] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::addAirPressure(const WeatherPrecition alt, const WeatherPrecition x)
|
void FGMicroWeather::addAirPressure(const WeatherPrecision alt, const WeatherPrecision x)
|
||||||
{
|
{
|
||||||
cerr << "Error: caught attempt to add AirPressure which is logical wrong\n";
|
cerr << "Error: caught attempt to add AirPressure which is logical wrong\n";
|
||||||
//StoredWeather.AirPressure[alt] = x;
|
//StoredWeather.AirPressure[alt] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x)
|
void FGMicroWeather::addVaporPressure(const WeatherPrecision alt, const WeatherPrecision x)
|
||||||
{
|
{
|
||||||
StoredWeather.VaporPressure[alt] = x;
|
StoredWeather.VaporPressure[alt] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::addCloud(const WeatherPrecition alt, const FGCloudItem& x)
|
void FGMicroWeather::addCloud(const WeatherPrecision alt, const FGCloudItem& x)
|
||||||
{
|
{
|
||||||
StoredWeather.Clouds[alt] = x;
|
StoredWeather.Clouds[alt] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::setSnowRainIntensity(const WeatherPrecition& x)
|
void FGMicroWeather::setSnowRainIntensity(const WeatherPrecision x)
|
||||||
{
|
{
|
||||||
StoredWeather.SnowRainIntensity = x;
|
StoredWeather.SnowRainIntensity = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::setSnowRainType(const SnowRainType& x)
|
void FGMicroWeather::setSnowRainType(const SnowRainType x)
|
||||||
{
|
{
|
||||||
StoredWeather.snowRainType = x;
|
StoredWeather.snowRainType = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGMicroWeather::setLightningProbability(const WeatherPrecition& x)
|
void FGMicroWeather::setLightningProbability(const WeatherPrecision x)
|
||||||
{
|
{
|
||||||
StoredWeather.LightningProbability = x;
|
StoredWeather.LightningProbability = x;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +126,7 @@ inline const int FG_SIGN(const T& x) {
|
||||||
return x < T(0) ? -1 : 1;
|
return x < T(0) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FGMicroWeather::hasPoint(const Point2D& p) const
|
bool FGMicroWeather::hasPoint(const sgVec2& p) const
|
||||||
{
|
{
|
||||||
if (position.size()==0)
|
if (position.size()==0)
|
||||||
return true; //no border => this tile is infinite
|
return true; //no border => this tile is infinite
|
||||||
|
@ -132,7 +136,7 @@ bool FGMicroWeather::hasPoint(const Point2D& p) const
|
||||||
|
|
||||||
//when I'm here I've got at least 2 points
|
//when I'm here I've got at least 2 points
|
||||||
|
|
||||||
WeatherPrecition t;
|
WeatherPrecision t;
|
||||||
signed char side1, side2;
|
signed char side1, side2;
|
||||||
const_positionListIt it = position.begin();
|
const_positionListIt it = position.begin();
|
||||||
const_positionListIt it2 = it; it2++;
|
const_positionListIt it2 = it; it2++;
|
||||||
|
@ -143,19 +147,21 @@ bool FGMicroWeather::hasPoint(const Point2D& p) const
|
||||||
if (it2 == position.end())
|
if (it2 == position.end())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (fabs(it->x() - it2->x()) >= FG_EPSILON)
|
if (fabs(it->p[0] - it2->p[0]) >= FG_EPSILON)
|
||||||
{
|
{
|
||||||
t = (it->y() - it2->y()) / (it->x() - it2->x());
|
t = (it->p[1] - it2->p[1]) / (it->p[0] - it2->p[0]);
|
||||||
side1 = FG_SIGN (t * (StoredWeather.p.x() - it2->x()) + it2->y() - StoredWeather.p.y());
|
|
||||||
side2 = FG_SIGN (t * ( p.x() - it2->x()) + it2->y() - p.y());
|
side1 = FG_SIGN (t * (StoredWeather.p[0] - it2->p[0]) + it2->p[1] - StoredWeather.p[1]);
|
||||||
|
side2 = FG_SIGN (t * ( p[0] - it2->p[0]) + it2->p[1] - p[1]);
|
||||||
if ( side1 != side2 )
|
if ( side1 != side2 )
|
||||||
return false; //cout << "failed side check\n";
|
return false; //cout << "failed side check\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = (it->x() - it2->x()) / (it->y() - it2->y());
|
t = (it->p[0] - it2->p[0]) / (it->p[1] - it2->p[1]);
|
||||||
side1 = FG_SIGN (t * (StoredWeather.p.y() - it2->y()) + it2->x() - StoredWeather.p.x());
|
|
||||||
side2 = FG_SIGN (t * ( p.y() - it2->y()) + it2->x() - p.x());
|
side1 = FG_SIGN (t * (StoredWeather.p[1] - it2->p[1]) + it2->p[0] - StoredWeather.p[0]);
|
||||||
|
side2 = FG_SIGN (t * ( p[1] - it2->p[1]) + it2->p[0] - p[0]);
|
||||||
if ( side1 != side2 )
|
if ( side1 != side2 )
|
||||||
return false; //cout << "failed side check\n";
|
return false; //cout << "failed side check\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
30.06.1999 Christian Mayer STL portability
|
30.06.1999 Christian Mayer STL portability
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -46,22 +48,23 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "sg.h"
|
||||||
|
#include "FGWeatherVectorWrap.h"
|
||||||
|
|
||||||
|
#include "FGWeatherDefs.h"
|
||||||
|
|
||||||
//Include all the simulated weather features
|
//Include all the simulated weather features
|
||||||
#include "FGCloud.h"
|
#include "FGCloud.h"
|
||||||
#include "FGSnowRain.h"
|
#include "FGSnowRain.h"
|
||||||
|
|
||||||
#include "FGAirPressureItem.h"
|
#include "FGAirPressureItem.h"
|
||||||
#include "FGTemperatureItem.h"
|
|
||||||
#include "FGWindItem.h"
|
#include "FGWindItem.h"
|
||||||
#include "FGTurbulenceItem.h"
|
#include "FGTurbulenceItem.h"
|
||||||
#include "FGVaporPressureItem.h"
|
|
||||||
|
|
||||||
#include "FGWeatherDefs.h"
|
|
||||||
#include "FGPhysicalProperties.h"
|
#include "FGPhysicalProperties.h"
|
||||||
#include "FGPhysicalProperty.h"
|
#include "FGPhysicalProperty.h"
|
||||||
#include <Voronoi/point2d.h>
|
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
|
@ -76,13 +79,12 @@ class FGMicroWeather
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
protected:
|
protected:
|
||||||
typedef vector<Point2D> positionList;
|
typedef vector<sgVec2Wrap> positionList;
|
||||||
typedef positionList::iterator positionListIt;
|
typedef positionList::iterator positionListIt;
|
||||||
typedef positionList::const_iterator const_positionListIt;
|
typedef positionList::const_iterator const_positionListIt;
|
||||||
positionList position; //the points that specify the outline of the
|
positionList position; //the points that specify the outline of the
|
||||||
//micro weather (lat/lon)
|
//micro weather (lat/lon)
|
||||||
|
|
||||||
|
|
||||||
FGPhysicalProperties2D StoredWeather; //property if nothing is specified
|
FGPhysicalProperties2D StoredWeather; //property if nothing is specified
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -95,39 +97,45 @@ public:
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Add a feature to the micro weather */
|
/* Add a feature to the micro weather */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void addWind(const WeatherPrecition alt, const Point3D& x);
|
void addWind (const WeatherPrecision alt, const FGWindItem& x);
|
||||||
void addTurbulence(const WeatherPrecition alt, const Point3D& x);
|
void addTurbulence (const WeatherPrecision alt, const FGTurbulenceItem& x);
|
||||||
void addTemperature(const WeatherPrecition alt, const WeatherPrecition x);
|
void addTemperature (const WeatherPrecision alt, const WeatherPrecision x);
|
||||||
void addAirPressure(const WeatherPrecition alt, const WeatherPrecition x);
|
void addAirPressure (const WeatherPrecision alt, const WeatherPrecision x);
|
||||||
void addVaporPressure(const WeatherPrecition alt, const WeatherPrecition x);
|
void addVaporPressure(const WeatherPrecision alt, const WeatherPrecision x);
|
||||||
void addCloud(const WeatherPrecition alt, const FGCloudItem& x);
|
void addCloud (const WeatherPrecision alt, const FGCloudItem& x);
|
||||||
|
|
||||||
void setSnowRainIntensity(const WeatherPrecition& x);
|
void setSnowRainIntensity (const WeatherPrecision x);
|
||||||
void setSnowRainType(const SnowRainType& x);
|
void setSnowRainType (const SnowRainType x);
|
||||||
void setLightningProbability(const WeatherPrecition& x);
|
void setLightningProbability(const WeatherPrecision x);
|
||||||
|
|
||||||
void setStoredWeather(const FGPhysicalProperties2D& x);
|
void setStoredWeather (const FGPhysicalProperties2D& x);
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* get physical properties in the micro weather */
|
/* get physical properties in the micro weather */
|
||||||
/* NOTE: I don't neet to speify a positon as the properties don't */
|
/* NOTE: I don't neet to speify a positon as the properties don't */
|
||||||
/* change in a micro weather */
|
/* change in a micro weather */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
inline FGPhysicalProperty get(const WeatherPrecition& altitude) const
|
FGPhysicalProperties get(void) const
|
||||||
{
|
|
||||||
return FGPhysicalProperty(StoredWeather, altitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline FGPhysicalProperties get(void) const
|
|
||||||
{
|
{
|
||||||
return FGPhysicalProperties();
|
return FGPhysicalProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FGPhysicalProperty get(const WeatherPrecision altitude) const
|
||||||
|
{
|
||||||
|
return FGPhysicalProperty(StoredWeather, altitude);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* return true if p is inside this micro weather */
|
/* return true if p is inside this micro weather */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
inline bool hasPoint(const Point3D& p) const { return hasPoint((Point2D) p); }
|
bool hasPoint(const sgVec2& p) const;
|
||||||
bool hasPoint(const Point2D& p) const;
|
bool hasPoint(const sgVec3& p) const
|
||||||
|
{
|
||||||
|
sgVec2 temp;
|
||||||
|
sgSetVec2(temp, p[0], p[1]);
|
||||||
|
|
||||||
|
return hasPoint( temp );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: main program
|
Called by: main program
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -48,15 +50,17 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FGPhysicalProperties::FGPhysicalProperties()
|
FGPhysicalProperties::FGPhysicalProperties()
|
||||||
{
|
{
|
||||||
|
sgVec3 zero;
|
||||||
|
sgZeroVec3( zero );
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* This standart constructor fills the class with a standard weather */
|
/* This standart constructor fills the class with a standard weather */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
Wind[-1000.0] = Point3D(0.0); //no Wind by default
|
Wind[-1000.0] = FGWindItem(zero); //no Wind by default
|
||||||
Wind[10000.0] = Point3D(0.0); //no Wind by default
|
Wind[10000.0] = FGWindItem(zero); //no Wind by default
|
||||||
|
|
||||||
Turbulence[-1000.0] = Point3D(0.0); //no Turbulence by default
|
Turbulence[-1000.0] = FGTurbulenceItem(zero); //no Turbulence by default
|
||||||
Turbulence[10000.0] = Point3D(0.0); //no Turbulence by default
|
Turbulence[10000.0] = FGTurbulenceItem(zero); //no Turbulence by default
|
||||||
|
|
||||||
//Initialice with the CINA atmosphere
|
//Initialice with the CINA atmosphere
|
||||||
Temperature[ 0.0] = +15.0 + 273.16;
|
Temperature[ 0.0] = +15.0 + 273.16;
|
||||||
|
@ -81,7 +85,7 @@ unsigned int FGPhysicalProperties::getNumberOfCloudLayers(void) const
|
||||||
|
|
||||||
FGCloudItem FGPhysicalProperties::getCloudLayer(unsigned int nr) const
|
FGCloudItem FGPhysicalProperties::getCloudLayer(unsigned int nr) const
|
||||||
{
|
{
|
||||||
map<WeatherPrecition,FGCloudItem>::const_iterator CloudsIt = Clouds.begin();
|
map<WeatherPrecision,FGCloudItem>::const_iterator CloudsIt = Clouds.begin();
|
||||||
|
|
||||||
//set the iterator to the 'nr'th entry
|
//set the iterator to the 'nr'th entry
|
||||||
for (; nr > 0; nr--)
|
for (; nr > 0; nr--)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/*******-*- Mode: C++ -*-************************************************************
|
/*****************************************************************************
|
||||||
|
|
||||||
Header: FGPhysicalProperties.h
|
Header: FGPhysicalProperties.h
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -36,6 +36,8 @@ HISTORY
|
||||||
30.06.1999 Christian Mayer STL portability
|
30.06.1999 Christian Mayer STL portability
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -48,124 +50,136 @@ HISTORY
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include <Include/compiler.h>
|
#include <Include/compiler.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include "sg.h"
|
||||||
|
|
||||||
|
#include "FGWeatherDefs.h"
|
||||||
|
|
||||||
|
#include "FGAirPressureItem.h"
|
||||||
|
#include "FGWindItem.h"
|
||||||
|
#include "FGTurbulenceItem.h"
|
||||||
|
|
||||||
|
#include "FGCloudItem.h"
|
||||||
|
#include "FGSnowRain.h"
|
||||||
|
|
||||||
FG_USING_STD(vector);
|
FG_USING_STD(vector);
|
||||||
FG_USING_STD(map);
|
FG_USING_STD(map);
|
||||||
FG_USING_NAMESPACE(std);
|
FG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
#include <Math/point3d.hxx>
|
/****************************************************************************/
|
||||||
#include <Voronoi/point2d.h>
|
/* FOREWARD DEFINITIONS */
|
||||||
#include "FGWeatherDefs.h"
|
/****************************************************************************/
|
||||||
|
class FGPhysicalProperties2D;
|
||||||
#include "FGAirPressureItem.h"
|
ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
|
||||||
|
|
||||||
#include "FGCloudItem.h"
|
|
||||||
#include "FGSnowRain.h"
|
|
||||||
|
|
||||||
class FGPhysicalProperties
|
class FGPhysicalProperties
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef WeatherPrecition Altitude;
|
typedef WeatherPrecision Altitude;
|
||||||
|
|
||||||
map<Altitude,Point3D> Wind; //all Wind vectors
|
map<Altitude,FGWindItem> Wind; //all Wind vectors
|
||||||
map<Altitude,Point3D> Turbulence; //all Turbulence vectors
|
map<Altitude,FGTurbulenceItem> Turbulence; //all Turbulence vectors
|
||||||
map<Altitude,WeatherPrecition> Temperature; //in deg. Kelvin (I *only* accept SI!)
|
map<Altitude,WeatherPrecision> Temperature; //in deg. Kelvin (I *only* accept SI!)
|
||||||
FGAirPressureItem AirPressure; //in Pascal (I *only* accept SI!)
|
FGAirPressureItem AirPressure; //in Pascal (I *only* accept SI!)
|
||||||
map<Altitude,WeatherPrecition> VaporPressure; //in Pascal (I *only* accept SI!)
|
map<Altitude,WeatherPrecision> VaporPressure; //in Pascal (I *only* accept SI!)
|
||||||
|
|
||||||
map<Altitude,FGCloudItem> Clouds; //amount of covering and type
|
map<Altitude,FGCloudItem> Clouds; //amount of covering and type
|
||||||
|
|
||||||
WeatherPrecition SnowRainIntensity; //this also stands for hail, snow,...
|
WeatherPrecision SnowRainIntensity; //this also stands for hail, snow,...
|
||||||
SnowRainType snowRainType;
|
SnowRainType snowRainType;
|
||||||
WeatherPrecition LightningProbability;
|
WeatherPrecision LightningProbability;
|
||||||
|
|
||||||
FGPhysicalProperties(); //consructor to fill it with FG standart weather
|
FGPhysicalProperties(); //consructor to fill it with FG standart weather
|
||||||
|
|
||||||
//return values at specified altitudes
|
//return values at specified altitudes
|
||||||
Point3D WindAt(const WeatherPrecition& a) const;
|
void WindAt (sgVec3 ret, const WeatherPrecision a) const;
|
||||||
Point3D TurbulenceAt(const WeatherPrecition& a) const;
|
void TurbulenceAt (sgVec3 ret, const WeatherPrecision a) const;
|
||||||
WeatherPrecition TemperatureAt(const WeatherPrecition& a) const;
|
WeatherPrecision TemperatureAt (const WeatherPrecision a) const;
|
||||||
WeatherPrecition AirPressureAt(const WeatherPrecition& a) const;
|
WeatherPrecision AirPressureAt (const WeatherPrecision a) const;
|
||||||
WeatherPrecition VaporPressureAt(const WeatherPrecition& a) const;
|
WeatherPrecision VaporPressureAt(const WeatherPrecision a) const;
|
||||||
|
|
||||||
//for easier access to the cloud stuff:
|
//for easier access to the cloud stuff:
|
||||||
unsigned int getNumberOfCloudLayers(void) const;
|
unsigned int getNumberOfCloudLayers(void) const;
|
||||||
FGCloudItem getCloudLayer(unsigned int nr) const;
|
FGCloudItem getCloudLayer(unsigned int nr) const;
|
||||||
|
|
||||||
FGPhysicalProperties& operator = ( const FGPhysicalProperties& p );
|
FGPhysicalProperties& operator = ( const FGPhysicalProperties& p );
|
||||||
FGPhysicalProperties& operator *= ( const WeatherPrecition& d );
|
FGPhysicalProperties& operator *= ( const WeatherPrecision d );
|
||||||
FGPhysicalProperties& operator += ( const FGPhysicalProperties& p);
|
FGPhysicalProperties& operator += ( const FGPhysicalProperties& p );
|
||||||
FGPhysicalProperties& operator -= ( const FGPhysicalProperties& p);
|
FGPhysicalProperties& operator -= ( const FGPhysicalProperties& p );
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<FGPhysicalProperties> FGPhysicalPropertiesVector;
|
|
||||||
typedef FGPhysicalPropertiesVector::iterator FGPhysicalPropertiesVectorIt;
|
|
||||||
typedef FGPhysicalPropertiesVector::const_iterator FGPhysicalPropertiesVectorConstIt;
|
|
||||||
|
|
||||||
class FGPhysicalProperties2D;
|
|
||||||
ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
|
|
||||||
|
|
||||||
class FGPhysicalProperties2D : public FGPhysicalProperties
|
class FGPhysicalProperties2D : public FGPhysicalProperties
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Point2D p; //position of the property (lat/lon)
|
sgVec2 p; //position of the property (lat/lon)
|
||||||
friend ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
|
friend ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p );
|
||||||
|
|
||||||
FGPhysicalProperties2D() {}
|
FGPhysicalProperties2D() {}
|
||||||
|
|
||||||
FGPhysicalProperties2D(const FGPhysicalProperties& prop, const Point2D& pos)
|
FGPhysicalProperties2D(const FGPhysicalProperties& prop, const sgVec2& pos)
|
||||||
{
|
{
|
||||||
Wind = prop.Wind; Turbulence = prop.Turbulence; Temperature = prop.Temperature;
|
Wind = prop.Wind;
|
||||||
AirPressure = prop.AirPressure; VaporPressure = prop.VaporPressure; p = pos;
|
Turbulence = prop.Turbulence;
|
||||||
|
Temperature = prop.Temperature;
|
||||||
|
AirPressure = prop.AirPressure;
|
||||||
|
VaporPressure = prop.VaporPressure;
|
||||||
|
sgCopyVec2(p, pos);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<FGPhysicalProperties2D> FGPhysicalProperties2DVector;
|
typedef vector<FGPhysicalProperties> FGPhysicalPropertiesVector;
|
||||||
typedef FGPhysicalProperties2DVector::iterator FGPhysicalProperties2DVectorIt;
|
typedef FGPhysicalPropertiesVector::iterator FGPhysicalPropertiesVectorIt;
|
||||||
|
typedef FGPhysicalPropertiesVector::const_iterator FGPhysicalPropertiesVectorConstIt;
|
||||||
|
|
||||||
|
typedef vector<FGPhysicalProperties2D> FGPhysicalProperties2DVector;
|
||||||
|
typedef FGPhysicalProperties2DVector::iterator FGPhysicalProperties2DVectorIt;
|
||||||
typedef FGPhysicalProperties2DVector::const_iterator FGPhysicalProperties2DVectorConstIt;
|
typedef FGPhysicalProperties2DVector::const_iterator FGPhysicalProperties2DVectorConstIt;
|
||||||
|
|
||||||
inline ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p )
|
inline ostream& operator<< ( ostream& out, const FGPhysicalProperties2D& p )
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, Point3D >::const_iterator vector_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::const_iterator wind_iterator;
|
||||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
|
||||||
|
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||||
|
|
||||||
out << "Position: " << p.p << endl;
|
out << "Position: (" << p.p[0] << ", " << p.p[1] << ", " << p.p[2] << ")\n";
|
||||||
|
|
||||||
out << "Stored Wind: ";
|
out << "Stored Wind: ";
|
||||||
for (vector_iterator WindIt = p.Wind.begin();
|
for (wind_iterator WindIt = p.Wind.begin();
|
||||||
WindIt != p.Wind.end();
|
WindIt != p.Wind.end();
|
||||||
WindIt++)
|
WindIt++)
|
||||||
out << "(" << WindIt->first << ") at " << WindIt->second << "m; ";
|
out << "(" << WindIt->first << ") at (" << WindIt->second.x() << ", " << WindIt->second.y() << ", " << WindIt->second.z() << ") m; ";
|
||||||
out << endl;
|
out << "\n";
|
||||||
|
|
||||||
out << "Stored Turbulence: ";
|
out << "Stored Turbulence: ";
|
||||||
for (vector_iterator TurbulenceIt = p.Turbulence.begin();
|
for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
|
||||||
TurbulenceIt != p.Turbulence.end();
|
TurbulenceIt != p.Turbulence.end();
|
||||||
TurbulenceIt++)
|
TurbulenceIt++)
|
||||||
out << "(" << TurbulenceIt->first << ") at " << TurbulenceIt->second << "m; ";
|
out << "(" << TurbulenceIt->first << ") at (" << TurbulenceIt->second.x() << ", " << TurbulenceIt->second.y() << ", " << TurbulenceIt->second.z() << ") m; ";
|
||||||
out << endl;
|
out << "\n";
|
||||||
|
|
||||||
out << "Stored Temperature: ";
|
out << "Stored Temperature: ";
|
||||||
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
||||||
TemperatureIt != p.Temperature.end();
|
TemperatureIt != p.Temperature.end();
|
||||||
TemperatureIt++)
|
TemperatureIt++)
|
||||||
out << TemperatureIt->first << " at " << TemperatureIt->second << "m; ";
|
out << TemperatureIt->first << " at " << TemperatureIt->second << "m; ";
|
||||||
out << endl;
|
out << "\n";
|
||||||
|
|
||||||
out << "Stored AirPressure: ";
|
out << "Stored AirPressure: ";
|
||||||
out << p.AirPressure.getValue(0) << " at " << 0.0 << "m; ";
|
out << p.AirPressure.getValue(0) << " at " << 0.0 << "m; ";
|
||||||
out << endl;
|
out << "\n";
|
||||||
|
|
||||||
out << "Stored VaporPressure: ";
|
out << "Stored VaporPressure: ";
|
||||||
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
||||||
VaporPressureIt != p.VaporPressure.end();
|
VaporPressureIt != p.VaporPressure.end();
|
||||||
VaporPressureIt++)
|
VaporPressureIt++)
|
||||||
out << VaporPressureIt->first << " at " << VaporPressureIt->second << "m; ";
|
out << VaporPressureIt->first << " at " << VaporPressureIt->second << "m; ";
|
||||||
out << endl;
|
out << "\n";
|
||||||
|
|
||||||
return out << endl;
|
return out << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,31 +193,32 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator = ( const FGPhysical
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGPhysicalProperties& FGPhysicalProperties::operator *= ( const WeatherPrecition& d )
|
inline FGPhysicalProperties& FGPhysicalProperties::operator *= ( const WeatherPrecision d )
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, Point3D >::iterator vector_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::iterator wind_iterator;
|
||||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::iterator scalar_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::iterator turbulence_iterator;
|
||||||
|
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::iterator scalar_iterator;
|
||||||
|
|
||||||
for (vector_iterator WindIt = Wind.begin();
|
for (wind_iterator WindIt = Wind.begin();
|
||||||
WindIt != Wind.end();
|
WindIt != Wind.end();
|
||||||
WindIt++)
|
WindIt++)
|
||||||
WindIt->second *= d;
|
WindIt->second*= d;
|
||||||
|
|
||||||
for (vector_iterator TurbulenceIt = Turbulence.begin();
|
for (turbulence_iterator TurbulenceIt = Turbulence.begin();
|
||||||
TurbulenceIt != Turbulence.end();
|
TurbulenceIt != Turbulence.end();
|
||||||
TurbulenceIt++)
|
TurbulenceIt++)
|
||||||
TurbulenceIt->second *= d;
|
TurbulenceIt->second *= d;
|
||||||
|
|
||||||
for (scalar_iterator TemperatureIt = Temperature.begin();
|
for (scalar_iterator TemperatureIt = Temperature.begin();
|
||||||
TemperatureIt != Temperature.end();
|
TemperatureIt != Temperature.end();
|
||||||
TemperatureIt++)
|
TemperatureIt++)
|
||||||
TemperatureIt->second *= d;
|
TemperatureIt->second *= d;
|
||||||
|
|
||||||
AirPressure *= d;
|
AirPressure *= d;
|
||||||
|
|
||||||
for (scalar_iterator VaporPressureIt = VaporPressure.begin();
|
for (scalar_iterator VaporPressureIt = VaporPressure.begin();
|
||||||
VaporPressureIt != VaporPressure.end();
|
VaporPressureIt != VaporPressure.end();
|
||||||
VaporPressureIt++)
|
VaporPressureIt++)
|
||||||
VaporPressureIt->second *= d;
|
VaporPressureIt->second *= d;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -211,32 +226,33 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator *= ( const WeatherPr
|
||||||
|
|
||||||
inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysicalProperties& p)
|
inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysicalProperties& p)
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, Point3D >::const_iterator vector_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::const_iterator wind_iterator;
|
||||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
|
||||||
|
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||||
|
|
||||||
for (vector_iterator WindIt = p.Wind.begin();
|
for (wind_iterator WindIt = p.Wind.begin();
|
||||||
WindIt != p.Wind.end();
|
WindIt != p.Wind.end();
|
||||||
WindIt++ )
|
WindIt++)
|
||||||
if (!Wind.insert(*WindIt).second) //when it's not inserted => it's already existing
|
if (!Wind.insert(*WindIt).second) //when it's not inserted => it's already existing
|
||||||
Wind[WindIt->first] += WindIt->second; //=> add the value
|
Wind[WindIt->first] += WindIt->second; //=> add the value
|
||||||
|
|
||||||
for (vector_iterator TurbulenceIt = p.Turbulence.begin();
|
for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
|
||||||
TurbulenceIt != p.Turbulence.end();
|
TurbulenceIt != p.Turbulence.end();
|
||||||
TurbulenceIt++)
|
TurbulenceIt++)
|
||||||
if (!Turbulence.insert(*TurbulenceIt).second)
|
if (!Turbulence.insert(*TurbulenceIt).second)
|
||||||
Turbulence[TurbulenceIt->first] += TurbulenceIt->second;
|
Turbulence[TurbulenceIt->first] += TurbulenceIt->second;
|
||||||
|
|
||||||
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
||||||
TemperatureIt != p.Temperature.end();
|
TemperatureIt != p.Temperature.end();
|
||||||
TemperatureIt++)
|
TemperatureIt++)
|
||||||
if (!Temperature.insert(*TemperatureIt).second)
|
if (!Temperature.insert(*TemperatureIt).second)
|
||||||
Temperature[TemperatureIt->first] += TemperatureIt->second;
|
Temperature[TemperatureIt->first] += TemperatureIt->second;
|
||||||
|
|
||||||
AirPressure += p.AirPressure.getValue(0.0);
|
AirPressure += p.AirPressure.getValue(0.0);
|
||||||
|
|
||||||
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
||||||
VaporPressureIt != p.VaporPressure.end();
|
VaporPressureIt != p.VaporPressure.end();
|
||||||
VaporPressureIt++)
|
VaporPressureIt++)
|
||||||
if (!VaporPressure.insert(*VaporPressureIt).second)
|
if (!VaporPressure.insert(*VaporPressureIt).second)
|
||||||
VaporPressure[VaporPressureIt->first] += VaporPressureIt->second;
|
VaporPressure[VaporPressureIt->first] += VaporPressureIt->second;
|
||||||
|
|
||||||
|
@ -245,32 +261,33 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator += (const FGPhysical
|
||||||
|
|
||||||
inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
|
inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysicalProperties& p)
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, Point3D >::const_iterator vector_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGWindItem >::const_iterator wind_iterator;
|
||||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator turbulence_iterator;
|
||||||
|
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||||
|
|
||||||
for (vector_iterator WindIt = p.Wind.begin();
|
for (wind_iterator WindIt = p.Wind.begin();
|
||||||
WindIt != p.Wind.end();
|
WindIt != p.Wind.end();
|
||||||
WindIt++ )
|
WindIt++)
|
||||||
if (!Wind.insert( make_pair(WindIt->first, -WindIt->second) ).second) //when it's not inserted => it's already existing
|
if (!Wind.insert( make_pair(WindIt->first, -WindIt->second) ).second) //when it's not inserted => it's already existing
|
||||||
Wind[WindIt->first] -= WindIt->second; //=> substract the value
|
Wind[WindIt->first] -= WindIt->second; //=> substract the value
|
||||||
|
|
||||||
for (vector_iterator TurbulenceIt = p.Turbulence.begin();
|
for (turbulence_iterator TurbulenceIt = p.Turbulence.begin();
|
||||||
TurbulenceIt != p.Turbulence.end();
|
TurbulenceIt != p.Turbulence.end();
|
||||||
TurbulenceIt++)
|
TurbulenceIt++)
|
||||||
if (!Turbulence.insert( make_pair(TurbulenceIt->first, -TurbulenceIt->second) ).second)
|
if (!Turbulence.insert( make_pair(TurbulenceIt->first, -TurbulenceIt->second) ).second)
|
||||||
Turbulence[TurbulenceIt->first] -= TurbulenceIt->second;
|
Turbulence[TurbulenceIt->first] -= TurbulenceIt->second;
|
||||||
|
|
||||||
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
for (scalar_iterator TemperatureIt = p.Temperature.begin();
|
||||||
TemperatureIt != p.Temperature.end();
|
TemperatureIt != p.Temperature.end();
|
||||||
TemperatureIt++)
|
TemperatureIt++)
|
||||||
if (!Temperature.insert( make_pair(TemperatureIt->first, -TemperatureIt->second) ).second)
|
if (!Temperature.insert( make_pair(TemperatureIt->first, -TemperatureIt->second) ).second)
|
||||||
Temperature[TemperatureIt->first] -= TemperatureIt->second;
|
Temperature[TemperatureIt->first] -= TemperatureIt->second;
|
||||||
|
|
||||||
AirPressure -= p.AirPressure.getValue(0.0);
|
AirPressure -= p.AirPressure.getValue(0.0);
|
||||||
|
|
||||||
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
for (scalar_iterator VaporPressureIt = p.VaporPressure.begin();
|
||||||
VaporPressureIt != p.VaporPressure.end();
|
VaporPressureIt != p.VaporPressure.end();
|
||||||
VaporPressureIt++)
|
VaporPressureIt++)
|
||||||
if (!VaporPressure.insert( make_pair(VaporPressureIt->first, -VaporPressureIt->second) ).second)
|
if (!VaporPressure.insert( make_pair(VaporPressureIt->first, -VaporPressureIt->second) ).second)
|
||||||
VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second;
|
VaporPressure[VaporPressureIt->first] -= VaporPressureIt->second;
|
||||||
|
|
||||||
|
@ -279,33 +296,37 @@ inline FGPhysicalProperties& FGPhysicalProperties::operator -= (const FGPhysical
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Point3D FGPhysicalProperties::WindAt(const WeatherPrecition& a) const
|
inline void FGPhysicalProperties::WindAt(sgVec3 ret, const WeatherPrecision a) const
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, Point3D>::const_iterator vector_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGWindItem>::const_iterator vector_iterator;
|
||||||
|
|
||||||
vector_iterator it = Wind.lower_bound(a);
|
vector_iterator it = Wind.lower_bound(a);
|
||||||
vector_iterator it2 = it;
|
vector_iterator it2 = it;
|
||||||
it--;
|
it--;
|
||||||
|
|
||||||
//now I've got it->alt < a < it2->alt so I can interpolate
|
//now I've got it->alt < a < it2->alt so I can interpolate
|
||||||
return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
|
sgSubVec3(ret, *it2->second.getValue(), *it->second.getValue());
|
||||||
|
sgScaleVec3(ret, (a - it2->first) / (it2->first - it->first));
|
||||||
|
sgAddVec3(ret, *it2->second.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Point3D FGPhysicalProperties::TurbulenceAt(const WeatherPrecition& a) const
|
inline void FGPhysicalProperties::TurbulenceAt(sgVec3 ret, const WeatherPrecision a) const
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, Point3D>::const_iterator vector_iterator;
|
typedef map<FGPhysicalProperties::Altitude, FGTurbulenceItem>::const_iterator vector_iterator;
|
||||||
|
|
||||||
vector_iterator it = Turbulence.lower_bound(a);
|
vector_iterator it = Turbulence.lower_bound(a);
|
||||||
vector_iterator it2 = it;
|
vector_iterator it2 = it;
|
||||||
it--;
|
it--;
|
||||||
|
|
||||||
//now I've got it->alt < a < it2->alt so I can interpolate
|
//now I've got it->alt < a < it2->alt so I can interpolate
|
||||||
return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
|
sgSubVec3(ret, *it2->second.getValue(), *it->second.getValue());
|
||||||
|
sgScaleVec3(ret, (a - it2->first) / (it2->first - it->first));
|
||||||
|
sgAddVec3(ret, *it2->second.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition FGPhysicalProperties::TemperatureAt(const WeatherPrecition& a) const
|
inline WeatherPrecision FGPhysicalProperties::TemperatureAt(const WeatherPrecision a) const
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
|
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||||
|
|
||||||
scalar_iterator it = Temperature.lower_bound(a);
|
scalar_iterator it = Temperature.lower_bound(a);
|
||||||
scalar_iterator it2 = it;
|
scalar_iterator it2 = it;
|
||||||
|
@ -315,14 +336,14 @@ inline WeatherPrecition FGPhysicalProperties::TemperatureAt(const WeatherPreciti
|
||||||
return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
|
return ( (it2->second - it->second)/(it2->first - it->first) ) * (a - it2->first) + it2->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition FGPhysicalProperties::AirPressureAt(const WeatherPrecition& a) const
|
inline WeatherPrecision FGPhysicalProperties::AirPressureAt(const WeatherPrecision a) const
|
||||||
{
|
{
|
||||||
return AirPressure.getValue(a);
|
return AirPressure.getValue(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition FGPhysicalProperties::VaporPressureAt(const WeatherPrecition& a) const
|
inline WeatherPrecision FGPhysicalProperties::VaporPressureAt(const WeatherPrecision a) const
|
||||||
{
|
{
|
||||||
typedef map<FGPhysicalProperties::Altitude, WeatherPrecition>::const_iterator scalar_iterator;
|
typedef map<FGPhysicalProperties::Altitude, WeatherPrecision>::const_iterator scalar_iterator;
|
||||||
|
|
||||||
scalar_iterator it = VaporPressure.lower_bound(a);
|
scalar_iterator it = VaporPressure.lower_bound(a);
|
||||||
scalar_iterator it2 = it;
|
scalar_iterator it2 = it;
|
||||||
|
@ -333,12 +354,12 @@ inline WeatherPrecition FGPhysicalProperties::VaporPressureAt(const WeatherPreci
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline FGPhysicalProperties operator * (FGPhysicalProperties a, const WeatherPrecition& b)
|
inline FGPhysicalProperties operator * (FGPhysicalProperties a, const WeatherPrecision b)
|
||||||
{
|
{
|
||||||
return a *= b;
|
return a *= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGPhysicalProperties operator * (const WeatherPrecition& b, FGPhysicalProperties a)
|
inline FGPhysicalProperties operator * (const WeatherPrecision b, FGPhysicalProperties a)
|
||||||
{
|
{
|
||||||
return a *= b;
|
return a *= b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: main program
|
Called by: main program
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,36 +35,34 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include "FGPhysicalProperty.h"
|
|
||||||
#include "FGWeatherDefs.h"
|
#include "FGWeatherDefs.h"
|
||||||
|
#include "FGPhysicalProperty.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/********************************** CODE ************************************/
|
/********************************** CODE ************************************/
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FGPhysicalProperty::FGPhysicalProperty()
|
FGPhysicalProperty::FGPhysicalProperty()
|
||||||
{
|
{
|
||||||
Wind.setx(0.0); //Wind vector
|
sgZeroVec3(Wind); //Wind vector
|
||||||
Wind.sety(0.0); //Wind vector
|
|
||||||
Wind.setz(0.0); //Wind vector
|
|
||||||
|
|
||||||
Turbulence.setx(0.0); //Turbulence vector
|
sgZeroVec3(Turbulence); //Turbulence vector
|
||||||
Turbulence.sety(0.0); //Turbulence vector
|
|
||||||
Turbulence.setz(0.0); //Turbulence vector
|
|
||||||
|
|
||||||
Temperature = FG_WEATHER_DEFAULT_TEMPERATURE; //a nice warm day
|
Temperature = FG_WEATHER_DEFAULT_TEMPERATURE; //a nice warm day
|
||||||
AirPressure = FG_WEATHER_DEFAULT_AIRPRESSURE; //mbar, that's ground level
|
AirPressure = FG_WEATHER_DEFAULT_AIRPRESSURE; //mbar, that's ground level
|
||||||
VaporPressure = FG_WEATHER_DEFAULT_VAPORPRESSURE; //that gives about 50% relatvie humidity
|
VaporPressure = FG_WEATHER_DEFAULT_VAPORPRESSURE; //that gives about 50% relatvie humidity
|
||||||
}
|
}
|
||||||
|
|
||||||
FGPhysicalProperty::FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecition& altitude)
|
FGPhysicalProperty::FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecision altitude)
|
||||||
{
|
{
|
||||||
Wind = p.WindAt(altitude);
|
p.WindAt(Wind, altitude);
|
||||||
Turbulence = p.TurbulenceAt(altitude);
|
p.TurbulenceAt(Turbulence, altitude);
|
||||||
Temperature = p.TemperatureAt(altitude);
|
Temperature = p.TemperatureAt(altitude);
|
||||||
AirPressure = p.AirPressureAt(altitude);
|
AirPressure = p.AirPressureAt(altitude);
|
||||||
VaporPressure = p.VaporPressureAt(altitude);
|
VaporPressure = p.VaporPressureAt(altitude);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -36,6 +36,8 @@ HISTORY
|
||||||
30.06.1999 Christian Mayer STL portability
|
30.06.1999 Christian Mayer STL portability
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -48,63 +50,68 @@ HISTORY
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include <Include/compiler.h>
|
#include <Include/compiler.h>
|
||||||
#include <vector>
|
|
||||||
FG_USING_STD(vector);
|
|
||||||
FG_USING_NAMESPACE(std);
|
|
||||||
|
|
||||||
#include <Math/point3d.hxx>
|
#include <vector>
|
||||||
#include <Voronoi/point2d.h>
|
|
||||||
|
#include "sg.h"
|
||||||
|
|
||||||
#include "FGWeatherDefs.h"
|
#include "FGWeatherDefs.h"
|
||||||
#include "FGPhysicalProperties.h"
|
#include "FGPhysicalProperties.h"
|
||||||
|
|
||||||
|
FG_USING_STD(vector);
|
||||||
|
FG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* used for output: */
|
/* used for output: */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
class FGPhysicalProperty;
|
||||||
|
bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
|
||||||
|
|
||||||
class FGPhysicalProperty
|
class FGPhysicalProperty
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
Point3D Wind; //Wind vector
|
sgVec3 Wind; //Wind vector
|
||||||
Point3D Turbulence; //Turbulence vector
|
sgVec3 Turbulence; //Turbulence vector
|
||||||
WeatherPrecition Temperature; //in deg. Kelvin (I *only* accept SI!)
|
WeatherPrecision Temperature; //in deg. Kelvin (I *only* accept SI!)
|
||||||
WeatherPrecition AirPressure; //in Pascal (I *only* accept SI!)
|
WeatherPrecision AirPressure; //in Pascal (I *only* accept SI!)
|
||||||
WeatherPrecition VaporPressure; //in Pascal (I *only* accept SI!)
|
WeatherPrecision VaporPressure; //in Pascal (I *only* accept SI!)
|
||||||
|
|
||||||
FGPhysicalProperty(); //consructor to fill it with FG standart weather
|
FGPhysicalProperty(); //consructor to fill it with FG standart weather
|
||||||
FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecition& altitude);
|
FGPhysicalProperty(const FGPhysicalProperties& p, const WeatherPrecision altitude);
|
||||||
|
|
||||||
//allow calculations for easier handling such as interpolating
|
//allow calculations for easier handling such as interpolating
|
||||||
FGPhysicalProperty& operator = ( const FGPhysicalProperty& p ); // assignment of a Point3D
|
FGPhysicalProperty& operator = ( const FGPhysicalProperty& p ); // assignment of a FGPhysicalProperty
|
||||||
FGPhysicalProperty& operator += ( const FGPhysicalProperty& p ); // incrementation by a Point3D
|
FGPhysicalProperty& operator += ( const FGPhysicalProperty& p ); // incrementation by a FGPhysicalProperty
|
||||||
FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p ); // decrementation by a Point3D
|
FGPhysicalProperty& operator -= ( const FGPhysicalProperty& p ); // decrementation by a FGPhysicalProperty
|
||||||
FGPhysicalProperty& operator *= ( const double& d ); // multiplication by a constant
|
FGPhysicalProperty& operator *= ( const double d ); // multiplication by a constant
|
||||||
FGPhysicalProperty& operator /= ( const double& d ); // division by a constant
|
FGPhysicalProperty& operator /= ( const double d ); // division by a constant
|
||||||
|
|
||||||
friend FGPhysicalProperty operator - (const FGPhysicalProperty& p); // -p1
|
friend FGPhysicalProperty operator - (const FGPhysicalProperty& p); // -p1
|
||||||
friend bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
|
friend bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b); // p1 == p2?
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
|
|
||||||
typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
|
|
||||||
typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
|
|
||||||
|
|
||||||
class FGPhysicalProperty3D : public FGPhysicalProperty
|
class FGPhysicalProperty3D : public FGPhysicalProperty
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
Point3D p; //position of the property (lat/lon/alt)
|
sgVec3 p; //position of the property (lat/lon/alt)
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
|
typedef vector<FGPhysicalProperty> FGPhysicalPropertyVector;
|
||||||
typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
|
typedef FGPhysicalPropertyVector::iterator FGPhysicalPropertyVectorIt;
|
||||||
|
typedef FGPhysicalPropertyVector::const_iterator FGPhysicalPropertyVectorConstIt;
|
||||||
|
|
||||||
|
typedef vector<FGPhysicalProperty3D> FGPhysicalProperty3DVector;
|
||||||
|
typedef FGPhysicalProperty3DVector::iterator FGPhysicalProperty3DVectorIt;
|
||||||
typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
|
typedef FGPhysicalProperty3DVector::const_iterator FGPhysicalProperty3DVectorConstIt;
|
||||||
|
|
||||||
inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
|
inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProperty& p )
|
||||||
{
|
{
|
||||||
Wind = p.Wind;
|
sgCopyVec3(Wind, p.Wind);
|
||||||
Turbulence = p.Turbulence;
|
sgCopyVec3(Turbulence, p.Turbulence);
|
||||||
Temperature = p.Temperature;
|
Temperature = p.Temperature;
|
||||||
AirPressure = p.AirPressure;
|
AirPressure = p.AirPressure;
|
||||||
VaporPressure = p.VaporPressure;
|
VaporPressure = p.VaporPressure;
|
||||||
|
@ -113,8 +120,8 @@ inline FGPhysicalProperty& FGPhysicalProperty::operator = ( const FGPhysicalProp
|
||||||
|
|
||||||
inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
|
inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalProperty& p )
|
||||||
{
|
{
|
||||||
Wind += p.Wind;
|
sgAddVec3(Wind, p.Wind);
|
||||||
Turbulence += p.Turbulence;
|
sgAddVec3(Turbulence, p.Turbulence);
|
||||||
Temperature += p.Temperature;
|
Temperature += p.Temperature;
|
||||||
AirPressure += p.AirPressure;
|
AirPressure += p.AirPressure;
|
||||||
VaporPressure += p.VaporPressure;
|
VaporPressure += p.VaporPressure;
|
||||||
|
@ -123,28 +130,28 @@ inline FGPhysicalProperty& FGPhysicalProperty::operator += ( const FGPhysicalPro
|
||||||
|
|
||||||
inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
|
inline FGPhysicalProperty& FGPhysicalProperty::operator -= ( const FGPhysicalProperty& p )
|
||||||
{
|
{
|
||||||
Wind -= p.Wind;
|
sgSubVec3(Wind, p.Wind);
|
||||||
Turbulence -= p.Turbulence;
|
sgSubVec3(Turbulence, p.Turbulence);
|
||||||
Temperature -= p.Temperature;
|
Temperature -= p.Temperature;
|
||||||
AirPressure -= p.AirPressure;
|
AirPressure -= p.AirPressure;
|
||||||
VaporPressure -= p.VaporPressure;
|
VaporPressure -= p.VaporPressure;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double& d )
|
inline FGPhysicalProperty& FGPhysicalProperty::operator *= ( const double d )
|
||||||
{
|
{
|
||||||
Wind *= d;
|
sgScaleVec3(Wind, d);
|
||||||
Turbulence *= d;
|
sgScaleVec3(Turbulence, d);
|
||||||
Temperature *= d;
|
Temperature *= d;
|
||||||
AirPressure *= d;
|
AirPressure *= d;
|
||||||
VaporPressure *= d;
|
VaporPressure *= d;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double& d )
|
inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double d )
|
||||||
{
|
{
|
||||||
Wind /= d;
|
sgScaleVec3(Wind, 1.0 / d);
|
||||||
Turbulence /= d;
|
sgScaleVec3(Turbulence, 1.0 / d);
|
||||||
Temperature /= d;
|
Temperature /= d;
|
||||||
AirPressure /= d;
|
AirPressure /= d;
|
||||||
VaporPressure /= d;
|
VaporPressure /= d;
|
||||||
|
@ -154,8 +161,8 @@ inline FGPhysicalProperty& FGPhysicalProperty::operator /= ( const double& d )
|
||||||
inline FGPhysicalProperty operator - (const FGPhysicalProperty& p)
|
inline FGPhysicalProperty operator - (const FGPhysicalProperty& p)
|
||||||
{
|
{
|
||||||
FGPhysicalProperty x;
|
FGPhysicalProperty x;
|
||||||
x.Wind = -p.Wind;
|
sgNegateVec3(x.Wind, p.Wind);
|
||||||
x.Turbulence = -p.Turbulence;
|
sgNegateVec3(x.Turbulence, p.Turbulence);
|
||||||
x.Temperature = -p.Temperature;
|
x.Temperature = -p.Temperature;
|
||||||
x.AirPressure = -p.AirPressure;
|
x.AirPressure = -p.AirPressure;
|
||||||
x.VaporPressure = -p.VaporPressure;
|
x.VaporPressure = -p.VaporPressure;
|
||||||
|
@ -165,8 +172,8 @@ inline FGPhysicalProperty operator - (const FGPhysicalProperty& p)
|
||||||
inline bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
|
inline bool operator == (const FGPhysicalProperty& a, const FGPhysicalProperty& b)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
(a.Wind == b.Wind) &&
|
sgEqualVec3(a.Wind, b.Wind) &&
|
||||||
(a.Turbulence == b.Turbulence) &&
|
sgEqualVec3(a.Turbulence, b.Turbulence) &&
|
||||||
(a.Temperature == b.Temperature) &&
|
(a.Temperature == b.Temperature) &&
|
||||||
(a.AirPressure == b.AirPressure) &&
|
(a.AirPressure == b.AirPressure) &&
|
||||||
(a.VaporPressure == b.VaporPressure));
|
(a.VaporPressure == b.VaporPressure));
|
||||||
|
@ -187,21 +194,20 @@ inline FGPhysicalProperty operator - (const FGPhysicalProperty& a, const FGPhysi
|
||||||
return FGPhysicalProperty(a) -= b;
|
return FGPhysicalProperty(a) -= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGPhysicalProperty operator * (const FGPhysicalProperty& a, const WeatherPrecition& b)
|
inline FGPhysicalProperty operator * (const FGPhysicalProperty& a, const WeatherPrecision b)
|
||||||
{
|
{
|
||||||
return FGPhysicalProperty(a) *= b;
|
return FGPhysicalProperty(a) *= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGPhysicalProperty operator * (const WeatherPrecition& b, const FGPhysicalProperty& a)
|
inline FGPhysicalProperty operator * (const WeatherPrecision b, const FGPhysicalProperty& a)
|
||||||
{
|
{
|
||||||
return FGPhysicalProperty(a) *= b;
|
return FGPhysicalProperty(a) *= b;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecition& b)
|
inline FGPhysicalProperty operator / (const FGPhysicalProperty& a, const WeatherPrecision b)
|
||||||
{
|
{
|
||||||
return FGPhysicalProperty(a) *= (1.0/b);
|
return FGPhysicalProperty(a) *= (1.0/b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#endif /*FGPhysicalProperty_H*/
|
#endif /*FGPhysicalProperty_H*/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -34,6 +34,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -48,7 +48,7 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include "FGWeatherDefs.h"
|
#include "FGWeatherDefs.h"
|
||||||
|
|
||||||
//for the case that mutable isn't supported:
|
// for the case that mutable isn't supported:
|
||||||
#include "Include/compiler.h"
|
#include "Include/compiler.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -63,20 +63,20 @@ FGTemperatureItem operator-(const FGTemperatureItem& arg);
|
||||||
class FGTemperatureItem
|
class FGTemperatureItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
mutable WeatherPrecition value;
|
mutable WeatherPrecision value;
|
||||||
WeatherPrecition alt;
|
WeatherPrecision alt;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGTemperatureItem(const WeatherPrecition& a, const WeatherPrecition& v) {alt = a; value = v;}
|
FGTemperatureItem(const WeatherPrecision& a, const WeatherPrecision& v) {alt = a; value = v;}
|
||||||
FGTemperatureItem(const WeatherPrecition& v) {alt = 0.0; value = v;}
|
FGTemperatureItem(const WeatherPrecision& v) {alt = 0.0; value = v;}
|
||||||
FGTemperatureItem() {alt = 0.0; value = (WeatherPrecition)FG_WEATHER_DEFAULT_TEMPERATURE;}
|
FGTemperatureItem() {alt = 0.0; value = (WeatherPrecision)FG_WEATHER_DEFAULT_TEMPERATURE;}
|
||||||
|
|
||||||
WeatherPrecition getValue() const { return value; };
|
WeatherPrecision getValue() const { return value; };
|
||||||
WeatherPrecition getAlt() const { return alt; };
|
WeatherPrecision getAlt() const { return alt; };
|
||||||
|
|
||||||
FGTemperatureItem& operator*= (const WeatherPrecition& arg);
|
FGTemperatureItem& operator*= (const WeatherPrecision& arg);
|
||||||
FGTemperatureItem& operator+= (const FGTemperatureItem& arg);
|
FGTemperatureItem& operator+= (const FGTemperatureItem& arg);
|
||||||
FGTemperatureItem& operator-= (const FGTemperatureItem& arg);
|
FGTemperatureItem& operator-= (const FGTemperatureItem& arg);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FGTemperatureItem& FGTemperatureItem::operator*= (const WeatherPrecition& arg)
|
inline FGTemperatureItem& FGTemperatureItem::operator*= (const WeatherPrecision& arg)
|
||||||
{
|
{
|
||||||
value *= arg;
|
value *= arg;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: FGMicroWeather
|
Called by: FGMicroWeather
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -45,8 +47,4 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/********************************** CODE ************************************/
|
/********************************** CODE ************************************/
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
bool operator<(const FGTurbulenceItem& arg1, const FGTurbulenceItem& arg2)
|
|
||||||
{
|
|
||||||
return arg1.alt < arg2.alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -32,9 +32,10 @@ HISTORY
|
||||||
28.05.1999 Christian Mayer Created
|
28.05.1999 Christian Mayer Created
|
||||||
16.06.1999 Durk Talsma Portability for Linux
|
16.06.1999 Durk Talsma Portability for Linux
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
|
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -46,12 +47,10 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include <Math/point3d.hxx>
|
#include "sg.h"
|
||||||
|
|
||||||
#include "FGWeatherDefs.h"
|
#include "FGWeatherDefs.h"
|
||||||
|
|
||||||
//for the case that mutable isn't supported:
|
|
||||||
#include "Include/compiler.h"
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -64,48 +63,52 @@ FGTurbulenceItem operator-(const FGTurbulenceItem& arg);
|
||||||
class FGTurbulenceItem
|
class FGTurbulenceItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
mutable Point3D value;
|
sgVec3 value;
|
||||||
WeatherPrecition alt;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
FGTurbulenceItem(const WeatherPrecition& a, const Point3D& v) {alt = a; value = v;}
|
FGTurbulenceItem(const sgVec3& v) { sgCopyVec3(value, v);}
|
||||||
FGTurbulenceItem(const Point3D& v) {alt = 0.0; value = v;}
|
FGTurbulenceItem() { sgZeroVec3(value); }
|
||||||
FGTurbulenceItem() {alt = 0.0; value = Point3D(0.0);}
|
|
||||||
|
|
||||||
Point3D getValue() const { return value; };
|
void getValue(sgVec3 ret) const { sgCopyVec3(ret, value); };
|
||||||
WeatherPrecition getAlt() const { return alt; };
|
const sgVec3* getValue(void) const { return &value; };
|
||||||
|
|
||||||
FGTurbulenceItem& operator*= (const WeatherPrecition& arg);
|
WeatherPrecision x(void) const { return value[0]; };
|
||||||
|
WeatherPrecision y(void) const { return value[1]; };
|
||||||
|
WeatherPrecision z(void) const { return value[2]; };
|
||||||
|
|
||||||
|
FGTurbulenceItem& operator*= (const WeatherPrecision arg);
|
||||||
FGTurbulenceItem& operator+= (const FGTurbulenceItem& arg);
|
FGTurbulenceItem& operator+= (const FGTurbulenceItem& arg);
|
||||||
FGTurbulenceItem& operator-= (const FGTurbulenceItem& arg);
|
FGTurbulenceItem& operator-= (const FGTurbulenceItem& arg);
|
||||||
|
|
||||||
friend bool operator<(const FGTurbulenceItem& arg1, const FGTurbulenceItem& arg2 );
|
|
||||||
friend FGTurbulenceItem operator-(const FGTurbulenceItem& arg);
|
friend FGTurbulenceItem operator-(const FGTurbulenceItem& arg);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FGTurbulenceItem& FGTurbulenceItem::operator*= (const WeatherPrecition& arg)
|
inline FGTurbulenceItem& FGTurbulenceItem::operator*= (const WeatherPrecision arg)
|
||||||
{
|
{
|
||||||
value *= arg;
|
sgScaleVec3(value, arg);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGTurbulenceItem& FGTurbulenceItem::operator+= (const FGTurbulenceItem& arg)
|
inline FGTurbulenceItem& FGTurbulenceItem::operator+= (const FGTurbulenceItem& arg)
|
||||||
{
|
{
|
||||||
value += arg.value;
|
sgAddVec3(value, *arg.getValue());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGTurbulenceItem& FGTurbulenceItem::operator-= (const FGTurbulenceItem& arg)
|
inline FGTurbulenceItem& FGTurbulenceItem::operator-= (const FGTurbulenceItem& arg)
|
||||||
{
|
{
|
||||||
value -= arg.value;
|
sgSubVec3(value, *arg.getValue());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGTurbulenceItem operator-(const FGTurbulenceItem& arg)
|
inline FGTurbulenceItem operator-(const FGTurbulenceItem& arg)
|
||||||
{
|
{
|
||||||
return FGTurbulenceItem(arg.alt, -arg.value);
|
sgVec3 temp;
|
||||||
|
|
||||||
|
sgNegateVec3(temp, *arg.getValue());
|
||||||
|
|
||||||
|
return FGTurbulenceItem(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -63,20 +63,20 @@ FGVaporPressureItem operator-(const FGVaporPressureItem& arg);
|
||||||
class FGVaporPressureItem
|
class FGVaporPressureItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
mutable WeatherPrecition value;
|
mutable WeatherPrecision value;
|
||||||
WeatherPrecition alt;
|
WeatherPrecision alt;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGVaporPressureItem(const WeatherPrecition& a, const WeatherPrecition& v) {alt = a; value = v;}
|
FGVaporPressureItem(const WeatherPrecision& a, const WeatherPrecision& v) {alt = a; value = v;}
|
||||||
FGVaporPressureItem(const WeatherPrecition& v) {alt = 0.0; value = v;}
|
FGVaporPressureItem(const WeatherPrecision& v) {alt = 0.0; value = v;}
|
||||||
FGVaporPressureItem() {alt = 0.0; value = FG_WEATHER_DEFAULT_VAPORPRESSURE;}
|
FGVaporPressureItem() {alt = 0.0; value = FG_WEATHER_DEFAULT_VAPORPRESSURE;}
|
||||||
|
|
||||||
WeatherPrecition getValue() const { return value; };
|
WeatherPrecision getValue() const { return value; };
|
||||||
WeatherPrecition getAlt() const { return alt; };
|
WeatherPrecision getAlt() const { return alt; };
|
||||||
|
|
||||||
FGVaporPressureItem& operator*= (const WeatherPrecition& arg);
|
FGVaporPressureItem& operator*= (const WeatherPrecision& arg);
|
||||||
FGVaporPressureItem& operator+= (const FGVaporPressureItem& arg);
|
FGVaporPressureItem& operator+= (const FGVaporPressureItem& arg);
|
||||||
FGVaporPressureItem& operator-= (const FGVaporPressureItem& arg);
|
FGVaporPressureItem& operator-= (const FGVaporPressureItem& arg);
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FGVaporPressureItem& FGVaporPressureItem::operator*= (const WeatherPrecition& arg)
|
inline FGVaporPressureItem& FGVaporPressureItem::operator*= (const WeatherPrecision& arg)
|
||||||
{
|
{
|
||||||
value *= arg;
|
value *= arg;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
Module: FGVoronoi.cpp
|
Module: FGVoronoi.cpp
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: main program
|
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -38,6 +37,8 @@ HISTORY
|
||||||
16.06.99 Durk Talsma Portability for Linux
|
16.06.99 Durk Talsma Portability for Linux
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -67,12 +68,12 @@ FGVoronoiOutputList Voronoiate(const FGVoronoiInputList& input)
|
||||||
|
|
||||||
PointList p2ds;
|
PointList p2ds;
|
||||||
|
|
||||||
FGVoronoiInputList::iterator it1;
|
FGVoronoiInputList::const_iterator it1;
|
||||||
|
|
||||||
//get the points
|
//get the points
|
||||||
for (it1 = (FGVoronoiInputList::iterator)input.begin(); it1 != input.end(); it1++)
|
for (it1 = input.begin(); it1 != input.end(); it1++)
|
||||||
{
|
{
|
||||||
p2ds.push_back(VoronoiPoint(it1->position.x(), it1->position.y()));
|
p2ds.push_back(VoronoiPoint(it1->position[0], it1->position[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
cl.clear(); //make sure that it's empty
|
cl.clear(); //make sure that it's empty
|
||||||
|
@ -104,28 +105,35 @@ FGVoronoiOutputList Voronoiate(const FGVoronoiInputList& input)
|
||||||
PointList::iterator it3 = it2->boundary.begin();
|
PointList::iterator it3 = it2->boundary.begin();
|
||||||
|
|
||||||
if (it3->infinity == false)
|
if (it3->infinity == false)
|
||||||
boundary.push_back( *it3 );
|
boundary.push_back( sgVec2Wrap(it3->p) );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Point2D direction_vector = *it3;
|
sgVec2 direction_vector;
|
||||||
|
sgCopyVec2(direction_vector, it3->p);
|
||||||
|
|
||||||
it3++;
|
it3++;
|
||||||
boundary.push_back( (*it3) + direction_vector);
|
sgAddVec2(direction_vector, it3->p);
|
||||||
|
|
||||||
|
boundary.push_back( direction_vector );
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; it3 != it2->boundary.end(); it3++)
|
for (; it3 != it2->boundary.end(); it3++)
|
||||||
{
|
{
|
||||||
boundary.push_back( *it3 );
|
boundary.push_back( sgVec2Wrap(it3->p) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it3--;
|
it3--;
|
||||||
if (it3->infinity == true)
|
if (it3->infinity == true)
|
||||||
{
|
{
|
||||||
Point2D direction_vector = *it3;
|
sgVec2 direction_vector;
|
||||||
|
sgCopyVec2(direction_vector, it3->p);
|
||||||
|
|
||||||
it3--;
|
it3--;
|
||||||
Point2D value = *it3;
|
sgAddVec2(direction_vector, it3->p);
|
||||||
|
|
||||||
boundary.pop_back();
|
boundary.pop_back();
|
||||||
boundary.push_back(value + direction_vector);
|
boundary.push_back(direction_vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret_list.push_back(FGVoronoiOutput(boundary, input[it2->ID].value));
|
ret_list.push_back(FGVoronoiOutput(boundary, input[it2->ID].value));
|
||||||
|
@ -182,8 +190,8 @@ bool readsites(PointList input)
|
||||||
|
|
||||||
while(It != input.end())
|
while(It != input.end())
|
||||||
{
|
{
|
||||||
sites[nsites].coord.x = It->x();
|
sites[nsites].coord.x = It->p[0];
|
||||||
sites[nsites].coord.y = It->y();
|
sites[nsites].coord.y = It->p[1];
|
||||||
|
|
||||||
sites[nsites].sitenbr = nsites;
|
sites[nsites].sitenbr = nsites;
|
||||||
sites[nsites].refcnt = 0;
|
sites[nsites].refcnt = 0;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -39,6 +39,8 @@ HISTORY
|
||||||
30.06.1999 Christian Mayer STL portability
|
30.06.1999 Christian Mayer STL portability
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -51,27 +53,32 @@ HISTORY
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include "compiler.h"
|
#include "compiler.h"
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include <Voronoi/point2d.h>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "sg.h"
|
||||||
|
|
||||||
|
#include "FGWeatherVectorWrap.h"
|
||||||
#include "FGPhysicalProperties.h"
|
#include "FGPhysicalProperties.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
FG_USING_STD(vector);
|
FG_USING_STD(vector);
|
||||||
FG_USING_STD(set);
|
|
||||||
FG_USING_NAMESPACE(std);
|
FG_USING_NAMESPACE(std);
|
||||||
|
|
||||||
typedef vector<Point2D> Point2DList;
|
typedef vector<sgVec2Wrap> Point2DList;
|
||||||
|
|
||||||
struct FGVoronoiInput
|
struct FGVoronoiInput
|
||||||
{
|
{
|
||||||
Point2D position;
|
sgVec2 position;
|
||||||
FGPhysicalProperties2D value;
|
FGPhysicalProperties2D value;
|
||||||
|
|
||||||
FGVoronoiInput(const Point2D& p, const FGPhysicalProperties2D& v) { position = p; value = v; }
|
FGVoronoiInput(const sgVec2& p, const FGPhysicalProperties2D& v)
|
||||||
|
{
|
||||||
|
sgCopyVec2(position, p);
|
||||||
|
value = v;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FGVoronoiOutput
|
struct FGVoronoiOutput
|
||||||
|
@ -79,10 +86,14 @@ struct FGVoronoiOutput
|
||||||
Point2DList boundary;
|
Point2DList boundary;
|
||||||
FGPhysicalProperties2D value;
|
FGPhysicalProperties2D value;
|
||||||
|
|
||||||
FGVoronoiOutput(const Point2DList& b, const FGPhysicalProperties2D& v) {boundary = b; value = v;};
|
FGVoronoiOutput(const Point2DList& b, const FGPhysicalProperties2D& v)
|
||||||
|
{
|
||||||
|
boundary = b;
|
||||||
|
value = v;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef vector<FGVoronoiInput> FGVoronoiInputList;
|
typedef vector<FGVoronoiInput> FGVoronoiInputList;
|
||||||
typedef vector<FGVoronoiOutput> FGVoronoiOutputList;
|
typedef vector<FGVoronoiOutput> FGVoronoiOutputList;
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -34,6 +34,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -49,7 +51,7 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
typedef float WeatherPrecition;
|
typedef float WeatherPrecision;
|
||||||
|
|
||||||
//set the minimum visibility to get a at least half way realistic weather
|
//set the minimum visibility to get a at least half way realistic weather
|
||||||
#define MINIMUM_WEATHER_VISIBILIY 10.0 /* metres */
|
#define MINIMUM_WEATHER_VISIBILIY 10.0 /* metres */
|
||||||
|
@ -57,10 +59,11 @@ typedef float WeatherPrecition;
|
||||||
//prefered way the database is working
|
//prefered way the database is working
|
||||||
#define PREFERED_WORKING_TYPE default_mode
|
#define PREFERED_WORKING_TYPE default_mode
|
||||||
|
|
||||||
#define FG_WEATHER_DEFAULT_TEMPERATURE (15.0+273.16) /*15°C or 288.16°K*/
|
#define FG_WEATHER_DEFAULT_TEMPERATURE (15.0+273.16) /*15°C or 288.16°K*/
|
||||||
#define FG_WEATHER_DEFAULT_VAPORPRESSURE (0.0) /*in Pascal 1 Pa = N/m^2*/
|
#define FG_WEATHER_DEFAULT_VAPORPRESSURE (0.0) /*in Pascal 1 Pa = N/m^2*/
|
||||||
#define FG_WEATHER_DEFAULT_AIRPRESSURE (1013.25*100.0) /*in Pascal 1 Pa = N/m^2*/
|
#define FG_WEATHER_DEFAULT_AIRPRESSURE (1013.25*100.0) /*in Pascal 1 Pa = N/m^2*/
|
||||||
#define FG_WEATHER_DEFAULT_AIRDENSITY (1.22501) /*in kg/m^3*/
|
#define FG_WEATHER_DEFAULT_AIRDENSITY (1.22501) /*in kg/m^3*/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* CLASS DECLARATION */
|
/* CLASS DECLARATION */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -36,6 +36,8 @@ HISTORY
|
||||||
30.06.1999 Christian Mayer STL portability
|
30.06.1999 Christian Mayer STL portability
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -48,11 +50,9 @@ HISTORY
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include <Include/compiler.h>
|
#include <Include/compiler.h>
|
||||||
#include <vector>
|
|
||||||
FG_USING_STD(vector);
|
|
||||||
FG_USING_NAMESPACE(std);
|
|
||||||
|
|
||||||
#include <Math/point3d.hxx>
|
#include "sg.h"
|
||||||
|
|
||||||
#include "FGWeatherDefs.h"
|
#include "FGWeatherDefs.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -74,15 +74,15 @@ class FGWeatherFeature
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
protected:
|
protected:
|
||||||
Point3D position; //middle of the feature in lat/lon/alt
|
sgVec3 position; //middle of the feature in lat/lon/alt
|
||||||
WeatherPrecition minSize; //smalest size of the feature
|
WeatherPrecision minSize; //smalest size of the feature
|
||||||
//=> a disk is specifies
|
//=> a disk is specifies
|
||||||
|
|
||||||
LayerType FeatureType;
|
LayerType FeatureType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LayerType getFeature(void) const { return FeatureType; }
|
LayerType getFeature(void) const { return FeatureType; }
|
||||||
bool isFeature(const LayerType& f) const {return (f == FeatureType);}
|
bool isFeature(const LayerType& f) const { return (f == FeatureType); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -78,7 +80,7 @@ HISTORY
|
||||||
#define SAT_VP_CONST2 7.444072452
|
#define SAT_VP_CONST2 7.444072452
|
||||||
#define SAT_VP_CONST3 235.3120919
|
#define SAT_VP_CONST3 235.3120919
|
||||||
|
|
||||||
inline WeatherPrecition sat_vp(const WeatherPrecition& temp)
|
inline WeatherPrecision sat_vp(const WeatherPrecision temp)
|
||||||
{
|
{
|
||||||
//old:
|
//old:
|
||||||
//return 6.112 * pow( 10, (7.5*dp)/(237.7+dp) ); //in mbar
|
//return 6.112 * pow( 10, (7.5*dp)/(237.7+dp) ); //in mbar
|
||||||
|
@ -90,21 +92,21 @@ inline WeatherPrecition sat_vp(const WeatherPrecition& temp)
|
||||||
return SAT_VP_CONST1 * pow( 10, (SAT_VP_CONST2*temp)/(SAT_VP_CONST3+temp) ); //in pascal
|
return SAT_VP_CONST1 * pow( 10, (SAT_VP_CONST2*temp)/(SAT_VP_CONST3+temp) ); //in pascal
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition rel_hum(const WeatherPrecition& act_vp, const WeatherPrecition& sat_vp)
|
inline WeatherPrecision rel_hum(const WeatherPrecision act_vp, const WeatherPrecision sat_vp)
|
||||||
{
|
{
|
||||||
return (act_vp / sat_vp) * 100; //in %
|
return (act_vp / sat_vp) * 100; //in %
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition dp(const WeatherPrecition& sat_vp)
|
inline WeatherPrecision dp(const WeatherPrecision sat_vp)
|
||||||
{
|
{
|
||||||
return (SAT_VP_CONST3*log10(sat_vp/SAT_VP_CONST1))/(SAT_VP_CONST2-log10(sat_vp/SAT_VP_CONST1)); //in °C
|
return (SAT_VP_CONST3*log10(sat_vp/SAT_VP_CONST1))/(SAT_VP_CONST2-log10(sat_vp/SAT_VP_CONST1)); //in °C
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition wb(const WeatherPrecition& t, const WeatherPrecition& p, const WeatherPrecition& dp)
|
inline WeatherPrecision wb(const WeatherPrecision t, const WeatherPrecision p, const WeatherPrecision dp)
|
||||||
{
|
{
|
||||||
WeatherPrecition e = sat_vp(dp);
|
WeatherPrecision e = sat_vp(dp);
|
||||||
WeatherPrecition tcur, tcvp, peq, diff;
|
WeatherPrecision tcur, tcvp, peq, diff;
|
||||||
WeatherPrecition tmin, tmax;
|
WeatherPrecision tmin, tmax;
|
||||||
|
|
||||||
if (t > dp)
|
if (t > dp)
|
||||||
{
|
{
|
||||||
|
@ -137,37 +139,37 @@ inline WeatherPrecition wb(const WeatherPrecition& t, const WeatherPrecition& p,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition Celsius(const WeatherPrecition& celsius)
|
inline WeatherPrecision Celsius(const WeatherPrecision celsius)
|
||||||
{
|
{
|
||||||
return celsius + 273.16; //Kelvin
|
return celsius + 273.16; //Kelvin
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition Fahrenheit(const WeatherPrecition& fahrenheit)
|
inline WeatherPrecision Fahrenheit(const WeatherPrecision fahrenheit)
|
||||||
{
|
{
|
||||||
return (fahrenheit * 9.0 / 5.0) + 32.0 + 273.16; //Kelvin
|
return (fahrenheit * 9.0 / 5.0) + 32.0 + 273.16; //Kelvin
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition Kelvin2Celsius(const WeatherPrecition& kelvin)
|
inline WeatherPrecision Kelvin2Celsius(const WeatherPrecision kelvin)
|
||||||
{
|
{
|
||||||
return kelvin - 273.16; //Celsius
|
return kelvin - 273.16; //Celsius
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition Kelvin2Fahrenheit(const WeatherPrecition& kelvin)
|
inline WeatherPrecision Kelvin2Fahrenheit(const WeatherPrecision kelvin)
|
||||||
{
|
{
|
||||||
return ((kelvin - 273.16) * 9.0 / 5.0) + 32.0; //Fahrenheit
|
return ((kelvin - 273.16) * 9.0 / 5.0) + 32.0; //Fahrenheit
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition Celsius2Fahrenheit(const WeatherPrecition& celsius)
|
inline WeatherPrecision Celsius2Fahrenheit(const WeatherPrecision celsius)
|
||||||
{
|
{
|
||||||
return (celsius * 9.0 / 5.0) + 32.0; //Fahrenheit
|
return (celsius * 9.0 / 5.0) + 32.0; //Fahrenheit
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition Fahrenheit2Celsius(const WeatherPrecition& fahrenheit)
|
inline WeatherPrecision Fahrenheit2Celsius(const WeatherPrecision fahrenheit)
|
||||||
{
|
{
|
||||||
return (fahrenheit - 32.0) * 5.0 / 9.0; //Celsius
|
return (fahrenheit - 32.0) * 5.0 / 9.0; //Celsius
|
||||||
}
|
}
|
||||||
|
|
||||||
inline WeatherPrecition Torr2Pascal(const WeatherPrecition& torr)
|
inline WeatherPrecision Torr2Pascal(const WeatherPrecision torr)
|
||||||
{
|
{
|
||||||
return (101325.0/760.0)*torr;
|
return (101325.0/760.0)*torr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
Called by: FGMicroWeather
|
Called by: FGMicroWeather
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -35,6 +35,8 @@ HISTORY
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -45,8 +47,4 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/********************************** CODE ************************************/
|
/********************************** CODE ************************************/
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
bool operator<(const FGWindItem& arg1, const FGWindItem& arg2)
|
|
||||||
{
|
|
||||||
return arg1.alt < arg2.alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Author: Christian Mayer
|
Author: Christian Mayer
|
||||||
Date started: 28.05.99
|
Date started: 28.05.99
|
||||||
|
|
||||||
---------- Copyright (C) 1999 Christian Mayer (vader@t-online.de) ----------
|
-------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
This program is free software; you can redistribute it and/or modify it under
|
||||||
the terms of the GNU General Public License as published by the Free Software
|
the terms of the GNU General Public License as published by the Free Software
|
||||||
|
@ -32,9 +32,10 @@ HISTORY
|
||||||
28.05.1999 Christian Mayer Created
|
28.05.1999 Christian Mayer Created
|
||||||
16.06.1999 Durk Talsma Portability for Linux
|
16.06.1999 Durk Talsma Portability for Linux
|
||||||
20.06.1999 Christian Mayer added lots of consts
|
20.06.1999 Christian Mayer added lots of consts
|
||||||
10.10.1999 Christian Mayer added mutable for gcc 2.95 portability
|
|
||||||
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
11.10.1999 Christian Mayer changed set<> to map<> on Bernie Bright's
|
||||||
suggestion
|
suggestion
|
||||||
|
19.10.1999 Christian Mayer change to use PLIB's sg instead of Point[2/3]D
|
||||||
|
and lots of wee code cleaning
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -46,12 +47,10 @@ HISTORY
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* INCLUDES */
|
/* INCLUDES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#include <Math/point3d.hxx>
|
#include "sg.h"
|
||||||
|
|
||||||
#include "FGWeatherDefs.h"
|
#include "FGWeatherDefs.h"
|
||||||
|
|
||||||
//for the case that mutable isn't supported:
|
|
||||||
#include "Include/compiler.h"
|
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* DEFINES */
|
/* DEFINES */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
@ -64,50 +63,55 @@ FGWindItem operator-(const FGWindItem& arg);
|
||||||
class FGWindItem
|
class FGWindItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
mutable Point3D value;
|
sgVec3 value;
|
||||||
WeatherPrecition alt;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGWindItem(const WeatherPrecition& a, const Point3D& v) {alt = a; value = v;}
|
FGWindItem(const sgVec3& v) { sgCopyVec3(value, v); }
|
||||||
FGWindItem(const Point3D& v) {alt = 0.0; value = v;}
|
FGWindItem() { sgZeroVec3(value); }
|
||||||
FGWindItem() {alt = 0.0; value = Point3D(0.0);}
|
|
||||||
|
|
||||||
Point3D getValue() const { return value; };
|
void getValue(sgVec3 ret) const { sgCopyVec3(ret, value); };
|
||||||
WeatherPrecition getAlt() const { return alt; };
|
const sgVec3* getValue(void) const { return &value; };
|
||||||
|
|
||||||
FGWindItem& operator*= (const WeatherPrecition& arg);
|
WeatherPrecision x(void) const { return value[0]; };
|
||||||
FGWindItem& operator+= (const FGWindItem& arg);
|
WeatherPrecision y(void) const { return value[1]; };
|
||||||
FGWindItem& operator-= (const FGWindItem& arg);
|
WeatherPrecision z(void) const { return value[2]; };
|
||||||
|
|
||||||
|
FGWindItem& operator*= (const WeatherPrecision arg);
|
||||||
|
FGWindItem& operator+= (const FGWindItem& arg);
|
||||||
|
FGWindItem& operator-= (const FGWindItem& arg);
|
||||||
|
|
||||||
friend bool operator<(const FGWindItem& arg1, const FGWindItem& arg2);
|
|
||||||
friend FGWindItem operator-(const FGWindItem& arg);
|
friend FGWindItem operator-(const FGWindItem& arg);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline FGWindItem& FGWindItem::operator*= (const WeatherPrecition& arg)
|
inline FGWindItem& FGWindItem::operator*= (const WeatherPrecision arg)
|
||||||
{
|
{
|
||||||
value *= arg;
|
sgScaleVec3(value, arg);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGWindItem& FGWindItem::operator+= (const FGWindItem& arg)
|
inline FGWindItem& FGWindItem::operator+= (const FGWindItem& arg)
|
||||||
{
|
{
|
||||||
value += arg.value;
|
sgAddVec3(value, *arg.getValue());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FGWindItem& FGWindItem::operator-= (const FGWindItem& arg)
|
inline FGWindItem& FGWindItem::operator-= (const FGWindItem& arg)
|
||||||
{
|
{
|
||||||
value -= arg.value;
|
sgSubVec3(value, *arg.getValue());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline FGWindItem operator-(const FGWindItem& arg)
|
inline FGWindItem operator-(const FGWindItem& arg)
|
||||||
{
|
{
|
||||||
return FGWindItem(arg.alt, -arg.value);
|
sgVec3 temp;
|
||||||
|
|
||||||
|
sgNegateVec3(temp, *arg.getValue());
|
||||||
|
|
||||||
|
return FGWindItem(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
#endif /*FGWindItem_H*/
|
#endif /*FGWindItem_H*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue