+++ /dev/null
-// fgwind.cxx -- routines to create variable winds
-//
-// Written by Torsten Dreyer
-//
-// Copyright (C) 2009 Torsten Dreyer - Torsten _at_ t3r*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 Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// $Id$
-#include "fgwind.hxx"
-#include <cmath>
-#include <stdio.h>
-
-FGWindModulator::FGWindModulator() :
- direction_offset_norm(0.0),
- magnitude_factor_norm(1.0)
-{
-}
-
-FGWindModulator::~FGWindModulator()
-{
-}
-
-FGBasicWindModulator::FGBasicWindModulator() :
- elapsed(0.0),
- direction_period(17),
- speed_period(1)
-{
-}
-
-FGBasicWindModulator::~FGBasicWindModulator()
-{
-}
-
-void FGBasicWindModulator::update( double dt)
-{
- elapsed += dt;
- double t = elapsed/direction_period;
-
- direction_offset_norm = (sin(t)*sin(2*t)+sin(t/3)) / 1.75;
-
- t = elapsed/speed_period;
- magnitude_factor_norm = sin(t)* sin(5*direction_offset_norm*direction_offset_norm);;
- magnitude_factor_norm = magnitude_factor_norm < 0 ? 0 : magnitude_factor_norm;
-}
+++ /dev/null
-// fgwind.hxx -- routines to create variable winds
-//
-// Written by Torsten Dreyer
-//
-// Copyright (C) 2009 Torsten Dreyer - Torsten _at_ t3r*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 Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// $Id$
-#ifndef _FGWIND_HXX
-#define _FGWIND_HXX
-
-#include <simgear/structure/SGReferenced.hxx>
-\f
-////////////////////////////////////////////////////////////////////////
-// A Wind Modulator interface, generates gusts and wind direction changes
-////////////////////////////////////////////////////////////////////////
-class FGWindModulator : public SGReferenced {
-public:
- FGWindModulator();
- virtual ~FGWindModulator();
- virtual void update( double dt ) = 0;
- double get_direction_offset_norm() const { return direction_offset_norm; }
- double get_magnitude_factor_norm() const { return magnitude_factor_norm; }
-protected:
- double direction_offset_norm;
- double magnitude_factor_norm;
-};
-
-\f
-////////////////////////////////////////////////////////////////////////
-// A Basic Wind Modulator, implementation of FGWindModulator
-// direction and magnitude variations are based on simple sin functions
-////////////////////////////////////////////////////////////////////////
-class FGBasicWindModulator : public FGWindModulator {
-public:
- FGBasicWindModulator();
- virtual ~FGBasicWindModulator();
- virtual void update( double dt );
- void set_direction_period( double _direction_period ) { direction_period = _direction_period; }
- double get_direction_period() const { return direction_period; }
- void set_speed_period( double _speed_period ) { speed_period = _speed_period; }
- double get_speed_period() const{ return speed_period; }
-private:
- double elapsed;
- double direction_period;
- double speed_period;
-};
-
-#endif