]> git.mxchange.org Git - flightgear.git/blob - src/WeatherCM/FGWindItem.h
ceffd6d025eece661ac72bf1c19124e1102b43dc
[flightgear.git] / src / WeatherCM / FGWindItem.h
1 /*****************************************************************************
2
3  Header:       FGWindItem.h     
4  Author:       Christian Mayer
5  Date started: 28.05.99
6
7  -------- Copyright (C) 1999 Christian Mayer (fgfs@christianmayer.de) --------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 FUNCTIONAL DESCRIPTION
27 ------------------------------------------------------------------------------
28 wind item that gets stored in the micro weather class
29
30 HISTORY
31 ------------------------------------------------------------------------------
32 28.05.1999 Christian Mayer      Created
33 16.06.1999 Durk Talsma          Portability for Linux
34 20.06.1999 Christian Mayer      added lots of consts
35 11.10.1999 Christian Mayer      changed set<> to map<> on Bernie Bright's 
36                                 suggestion
37 19.10.1999 Christian Mayer      change to use PLIB's sg instead of Point[2/3]D
38                                 and lots of wee code cleaning
39 *****************************************************************************/
40
41 /****************************************************************************/
42 /* SENTRY                                                                   */
43 /****************************************************************************/
44 #ifndef FGWindItem_H
45 #define FGWindItem_H
46
47 /****************************************************************************/
48 /* INCLUDES                                                                 */
49 /****************************************************************************/
50
51 #ifdef HAVE_CONFIG_H
52 #  include <config.h>
53 #endif
54
55 #include <Include/compiler.h>
56
57 #ifdef HAVE_WINDOWS_H
58 #  include <windows.h>
59 #endif
60
61 #include <sg.h>
62
63 #include "FGWeatherDefs.h"
64
65 /****************************************************************************/
66 /* DEFINES                                                                  */
67 /****************************************************************************/
68 class FGWindItem;
69 FGWindItem operator-(const FGWindItem& arg);
70
71 /****************************************************************************/
72 /* CLASS DECLARATION                                                        */
73 /****************************************************************************/
74 class FGWindItem
75 {
76 private:
77     sgVec3 value;
78
79 protected:
80 public:
81
82     FGWindItem(const sgVec3& v) { sgCopyVec3(value, v); }
83     FGWindItem(const WeatherPrecision x, const WeatherPrecision y, const WeatherPrecision z)    
84                                 { sgSetVec3 (value, x, y, z); }
85     FGWindItem()                { sgZeroVec3(value);    }
86
87     void          getValue(sgVec3 ret) const { sgCopyVec3(ret, value); };
88     const sgVec3* getValue(void)       const { return &value;          };
89
90     WeatherPrecision x(void) const { return value[0]; };
91     WeatherPrecision y(void) const { return value[1]; };
92     WeatherPrecision z(void) const { return value[2]; };
93
94     FGWindItem& operator*= (const WeatherPrecision arg);
95     FGWindItem& operator+= (const FGWindItem&      arg);
96     FGWindItem& operator-= (const FGWindItem&      arg);
97
98     friend FGWindItem operator-(const FGWindItem& arg);
99 };
100
101 inline FGWindItem& FGWindItem::operator*= (const WeatherPrecision arg)
102 {
103   sgScaleVec3(value, arg);
104   return *this;
105 }
106
107 inline FGWindItem& FGWindItem::operator+= (const FGWindItem& arg)
108 {
109   sgAddVec3(value, *arg.getValue());
110   return *this;
111 }
112
113 inline FGWindItem& FGWindItem::operator-= (const FGWindItem& arg)
114 {
115   sgSubVec3(value, *arg.getValue());
116   return *this;
117 }
118
119
120 inline FGWindItem operator-(const FGWindItem& arg)
121 {
122     sgVec3 temp;
123
124     sgNegateVec3(temp, *arg.getValue());
125
126     return FGWindItem(temp);
127 }
128
129 /****************************************************************************/
130 #endif /*FGWindItem_H*/