]> git.mxchange.org Git - flightgear.git/blobdiff - src/WeatherCM/FGWindItem.h
Erik Hofman:
[flightgear.git] / src / WeatherCM / FGWindItem.h
index 1376e453debf8d2da6a15141fe92f3894357a652..9aa6ab39577d9c6b29a72b51960429a203214ebd 100644 (file)
@@ -4,7 +4,7 @@
  Author:       Christian Mayer
  Date started: 28.05.99
 
  Author:       Christian Mayer
  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
  the terms of the GNU General Public License as published by the Free Software
 
  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
@@ -32,6 +32,12 @@ HISTORY
 28.05.1999 Christian Mayer     Created
 16.06.1999 Durk Talsma         Portability for Linux
 20.06.1999 Christian Mayer     added lots of consts
 28.05.1999 Christian Mayer     Created
 16.06.1999 Durk Talsma         Portability for Linux
 20.06.1999 Christian Mayer     added lots of consts
+11.10.1999 Christian Mayer     changed set<> to map<> on Bernie Bright's 
+                               suggestion
+19.10.1999 Christian Mayer     change to use PLIB's sg instead of Point[2/3]D
+                               and lots of wee code cleaning
+21.12.1999 Christian Mayer     Added a fix for compatibility to gcc 2.8 which
+                               suggested by Oliver Delise
 *****************************************************************************/
 
 /****************************************************************************/
 *****************************************************************************/
 
 /****************************************************************************/
@@ -43,65 +49,94 @@ HISTORY
 /****************************************************************************/
 /* INCLUDES                                                                */
 /****************************************************************************/
 /****************************************************************************/
 /* INCLUDES                                                                */
 /****************************************************************************/
-#include <Math/point3d.hxx>
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <simgear/compiler.h>
+
+#ifdef HAVE_WINDOWS_H
+#  include <windows.h>
+#endif
+
+#include <plib/sg.h>
+
 #include "FGWeatherDefs.h"
 #include "FGWeatherDefs.h"
-               
+
 /****************************************************************************/
 /* DEFINES                                                                 */
 /****************************************************************************/
 class FGWindItem;
 FGWindItem operator-(const FGWindItem& arg);
 
 /****************************************************************************/
 /* DEFINES                                                                 */
 /****************************************************************************/
 class FGWindItem;
 FGWindItem operator-(const FGWindItem& arg);
 
+#if ( __GNU_C__ == 2 && __GNU_MAJOR__ < 9 )
+#  define const_sgVec3 const sgVec3
+#else
+#  define const_sgVec3 const sgVec3&
+#endif
+
 /****************************************************************************/
 /* CLASS DECLARATION                                                       */
 /****************************************************************************/
 class FGWindItem
 {
 private:
 /****************************************************************************/
 /* CLASS DECLARATION                                                       */
 /****************************************************************************/
 class FGWindItem
 {
 private:
-    Point3D value;
-    WeatherPrecition alt;
+    sgVec3 value;
 
 protected:
 public:
 
 
 protected:
 public:
 
-    FGWindItem(const WeatherPrecition& a, const Point3D& v) {alt = a; value = v;}
-    FGWindItem(const Point3D& v)                           {alt = 0.0; value = v;}
-    FGWindItem()                                           {alt = 0.0; value = Point3D(0.0);}
+    FGWindItem(const_sgVec3 v) { sgCopyVec3(value, v); }
+    FGWindItem(const WeatherPrecision x, const WeatherPrecision y, const WeatherPrecision z)   
+                               { sgSetVec3 (value, x, y, z); }
+    FGWindItem()               { sgZeroVec3(value);    }
 
 
-    Point3D          getValue() const { return value; };
-    WeatherPrecition getAlt()   const { return alt;   };
+    void          getValue(sgVec3 ret) const { sgCopyVec3(ret, value); };
+    const sgVec3* getValue(void)       const { return &value;          };
 
 
-    FGWindItem& operator*= (const WeatherPrecition& arg);
-    FGWindItem& operator+= (const FGWindItem& arg);
-    FGWindItem& operator-= (const FGWindItem& arg);
+    WeatherPrecision x(void) const { return value[0]; };
+    WeatherPrecision y(void) const { return value[1]; };
+    WeatherPrecision z(void) const { return value[2]; };
 
 
-    friend bool operator<(const FGWindItem& arg1, const FGWindItem& arg2);
-    friend FGWindItem operator-(const FGWindItem& arg);
+    void x(const WeatherPrecision x) { value[0] = x; };
+    void y(const WeatherPrecision y) { value[1] = y; };
+    void z(const WeatherPrecision z) { value[2] = z; };
+
+    FGWindItem& operator*= (const WeatherPrecision arg);
+    FGWindItem& operator+= (const FGWindItem&      arg);
+    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;
 }
 
 inline FGWindItem& FGWindItem::operator+= (const FGWindItem& arg)
 {
   return *this;
 }
 
 inline FGWindItem& FGWindItem::operator+= (const FGWindItem& arg)
 {
-  value += arg.value;
+  sgAddVec3(value, *arg.getValue());
   return *this;
 }
 
 inline FGWindItem& FGWindItem::operator-= (const FGWindItem& arg)
 {
   return *this;
 }
 
 inline FGWindItem& FGWindItem::operator-= (const FGWindItem& arg)
 {
-  value -= arg.value;
+  sgSubVec3(value, *arg.getValue());
   return *this;
 }
 
 
 inline FGWindItem operator-(const FGWindItem& arg)
 {
   return *this;
 }
 
 
 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*/