Пример #1
0
        /// Converts to Rankine from one of several unit systems.
        protected double ConvertToRankine(double t, eTemperature unit)
        {
            double targetTemp = 0; // in degrees Rankine

            switch (unit)
            {
            case eTemperature.eFahrenheit:
                targetTemp = t + 459.67;
                break;

            case eTemperature.eCelsius:
                targetTemp = (t + 273.15) * 1.8;
                break;

            case eTemperature.eRankine:
                targetTemp = t;
                break;

            case eTemperature.eKelvin:
                targetTemp = t * 1.8;
                break;

            default:
                break;
            }

            return(targetTemp);
        }
Пример #2
0
        /// Converts from Rankine to one of several unit systems.
        protected double ConvertFromRankine(double t, eTemperature unit)
        {
            double targetTemp = 0;

            switch (unit)
            {
            case eTemperature.eFahrenheit:
                targetTemp = t - 459.67;
                break;

            case eTemperature.eCelsius:
                targetTemp = t / 1.8 - 273.15;
                break;

            case eTemperature.eRankine:
                targetTemp = t;
                break;

            case eTemperature.eKelvin:
                targetTemp = t / 1.8;
                break;

            default:
                break;
            }

            return(targetTemp);
        }
Пример #3
0
        //@}

        //  *************************************************************************
        ///@name Humidity access functions
        //@{

        /** Sets the dew point.
         *  @param dewpoint The dew point in the units specified
         *  @param unit The unit of measure that the specified dew point is supplied
         *              in. */
        public void SetDewPoint(eTemperature unit, double dewpoint)
        {
            double altitude      = CalculatePressureAltitude(Pressure, 0.0);
            double VaporPressure = CalculateVaporPressure(ConvertToRankine(dewpoint, unit));

            VaporMassFraction = Rdry * VaporPressure / (Rwater * (Pressure - VaporPressure));
            ValidateVaporMassFraction(altitude);
        }
Пример #4
0
 /// <summary>
 /// Sets the units presently specified for the model.
 /// </summary>
 /// <param name="forceUnits">The force units.</param>
 /// <param name="lengthUnits">The length units.</param>
 /// <param name="temperatureUnits">The temperature units.</param>
 public void SetPresentUnits(eForce forceUnits,
                             eLength lengthUnits,
                             eTemperature temperatureUnits)
 {
     _apiModel.SetPresentUnits(forceUnits, lengthUnits, temperatureUnits);
     UnitsForcePresent       = forceUnits;
     UnitsLengthPresent      = lengthUnits;
     UnitsTemperaturePresent = temperatureUnits;
 }
Пример #5
0
 /// Returns the temperature bias over the sea level value in degrees Rankine.
 public virtual double GetTemperatureBias(eTemperature to)
 {
     if (to == eTemperature.eCelsius || to == eTemperature.eKelvin)
     {
         return(temperatureBias / 1.80);
     }
     else
     {
         return(temperatureBias);
     }
 }
Пример #6
0
 /// Returns the temperature gradient to be applied on top of the standard
 /// temperature gradient.
 public virtual double GetTemperatureDeltaGradient(eTemperature to)
 {
     if (to == eTemperature.eCelsius || to == eTemperature.eKelvin)
     {
         return(temperatureDeltaGradient / 1.80);
     }
     else
     {
         return(temperatureDeltaGradient);
     }
 }
Пример #7
0
        /// Sets the temperature bias to be added to the standard temperature at all
        /// altitudes.
        /// This function sets the bias - the difference - from the standard
        /// atmosphere temperature. This bias applies to the entire
        /// temperature profile. Another way to set the temperature bias is to use the
        /// SetSLTemperature function, which replaces the value calculated by
        /// this function with a calculated bias.
        /// @param t the temperature value in the unit provided.
        /// @param unit the unit of the temperature.
        public virtual void SetTemperatureBias(eTemperature unit, double t)
        {
            if (unit == eTemperature.eCelsius || unit == eTemperature.eKelvin)
            {
                t *= 1.80; // If temp delta "t" is given in metric, scale up to English
            }
            temperatureBias = t;
            CalculatePressureBreakpoints(SLpressure);

            SLtemperature = GetTemperature(0.0);
            CalculateSLSoundSpeedAndDensity();
        }
Пример #8
0
    public void SetBiomeFields(eMoisture moist, eTemperature temp, eBiome biome)
    {
        _moisture = moist;
        _temp     = temp;
        _biome    = biome;

        // for now, durability will just be a straight addition of moisture/temp
        // drier/colder means harder, moist/warm means softer
        int count = System.Enum.GetNames(typeof(eMoisture)).Length;

        _durability = (count - (int)moist) + (int)temp;
    }
Пример #9
0
        /// Sets the temperature delta value at the supplied altitude/elevation above
        /// sea level, to be added to the standard temperature and ramped out by
        /// 86 km.
        /// This function computes the sea level delta from the standard atmosphere
        /// temperature at sea level.
        /// @param t the temperature skew value in the unit provided.
        /// @param unit the unit of the temperature.
        public virtual void SetTemperatureGradedDelta(double deltemp, double h, eTemperature unit = eTemperature.eFahrenheit)
        {
            if (unit == eTemperature.eCelsius || unit == eTemperature.eKelvin)
            {
                deltemp *= 1.80; // If temp delta "t" is given in metric, scale up to English
            }
            temperatureDeltaGradient = deltemp / (gradientFadeoutAltitude - GeopotentialAltitude(h));
            CalculateLapseRates();
            CalculatePressureBreakpoints(SLpressure);

            SLtemperature = GetTemperature(0.0);
            CalculateSLSoundSpeedAndDensity();
        }
Пример #10
0
        /// <summary>
        /// Sets the units presently specified for the model.
        /// </summary>
        /// <returns></returns>
        public void SetPresentUnits(eForce forceUnits,
                                    eLength lengthUnits,
                                    eTemperature temperatureUnits)
        {
            CSiProgram.eForce       csiForceUnits       = CSiProgram.eForce.NotApplicable;
            CSiProgram.eLength      csiLengthUnits      = CSiProgram.eLength.NotApplicable;
            CSiProgram.eTemperature csiTemperatureUnits = CSiProgram.eTemperature.NotApplicable;

            _callCode = _sapModel.SetPresentUnits_2(csiForceUnits, csiLengthUnits, csiTemperatureUnits);
            if (throwCurrentApiException(_callCode))
            {
                throw new CSiException();
            }
        }
Пример #11
0
        /***************************************************/

        public double DatabaseLengthUnitFactor()
        {
            eForce       force  = 0;
            eLength      length = 0;
            eTemperature temp   = 0;

            m_model.GetDatabaseUnits_2(ref force, ref length, ref temp);

            double factor = 1;

            switch (length)
            {
            case eLength.NotApplicable:
                Engine.Base.Compute.RecordWarning("Unknow NotApplicable unit, assumed to be meter.");
                factor = 1;
                break;

            case eLength.inch:
                factor = factor.ToInch();
                break;

            case eLength.ft:
                factor = factor.ToFoot();
                break;

            case eLength.micron:
                factor = factor.ToMicrometre();
                break;

            case eLength.mm:
                factor = factor.ToMillimetre();
                break;

            case eLength.cm:
                factor = factor.ToCentimetre();
                break;

            case eLength.m:
                factor = 1;
                break;

            default:
                break;
            }

            return(factor);
        }
Пример #12
0
        /** Returns the dew point.
         *  @param to The unit of measure that the dew point should be supplied in. */
        public double GetDewPoint(eTemperature to)
        {
            double dewpoint_degC;
            double VaporPressure = Pressure * VaporMassFraction / (VaporMassFraction + Rdry / Rwater);

            if (VaporPressure <= 0.0)
            {
                dewpoint_degC = -c;
            }
            else
            {
                double x = Math.Log(VaporPressure / a);
                dewpoint_degC = c * x / (b - x);
            }

            return(ConvertFromRankine(1.8 * (dewpoint_degC + 273.15), to));
        }
Пример #13
0
        /// Sets the temperature at the supplied altitude, if it is to be different
        /// than the standard temperature.
        /// This function will calculate a bias - a difference - from the standard
        /// atmosphere temperature at the supplied altitude and will apply that
        /// calculated bias to the entire temperature profile. If a graded delta is
        /// present, that will be included in the calculation - that is, regardless
        /// of any graded delta present, a temperature bias will be determined so that
        /// the temperature requested in this function call will be reached.
        /// @param t The temperature value in the unit provided.
        /// @param h The altitude in feet above sea level.
        /// @param unit The unit of the temperature.
        public override void SetTemperature(double t, double h, eTemperature unit = eTemperature.eFahrenheit)
        {
            double targetTemp = ConvertToRankine(t, unit);
            double GeoPotAlt  = GeopotentialAltitude(h);

            temperatureBias = targetTemp - GetStdTemperature(h);

            if (GeoPotAlt <= gradientFadeoutAltitude)
            {
                temperatureBias -= temperatureDeltaGradient * (gradientFadeoutAltitude - GeoPotAlt);
            }

            CalculatePressureBreakpoints(SLpressure);

            SLtemperature = GetTemperature(0.0);
            CalculateSLSoundSpeedAndDensity();
        }
Пример #14
0
        /// <summary>
        /// Returns the units presently specified for the model.
        /// </summary>
        /// <returns></returns>
        public void GetPresentUnits(ref eForce forceUnits,
                                    ref eLength lengthUnits,
                                    ref eTemperature temperatureUnits)
        {
            CSiProgram.eForce       csiForceUnits       = CSiProgram.eForce.NotApplicable;
            CSiProgram.eLength      csiLengthUnits      = CSiProgram.eLength.NotApplicable;
            CSiProgram.eTemperature csiTemperatureUnits = CSiProgram.eTemperature.NotApplicable;

            _callCode = _sapModel.GetPresentUnits_2(ref csiForceUnits, ref csiLengthUnits, ref csiTemperatureUnits);
            if (throwCurrentApiException(_callCode))
            {
                throw new CSiException();
            }

            forceUnits       = EnumLibrary.Convert(csiForceUnits, forceUnits);
            lengthUnits      = EnumLibrary.Convert(csiLengthUnits, lengthUnits);
            temperatureUnits = EnumLibrary.Convert(csiTemperatureUnits, temperatureUnits);
        }
Пример #15
0
        /// <summary>
        /// Returns the database units for the model.
        /// All data is internally stored in the model in these units and converted to the present units as needed.
        /// </summary>
        /// <returns></returns>
        public void GetDatabaseUnits(out eForce forceUnits,
                                     out eLength lengthUnits,
                                     out eTemperature temperatureUnits)
        {
            forceUnits       = 0;
            lengthUnits      = 0;
            temperatureUnits = 0;

            CSiProgram.eForce       csiForceUnits       = CSiProgram.eForce.NotApplicable;
            CSiProgram.eLength      csiLengthUnits      = CSiProgram.eLength.NotApplicable;
            CSiProgram.eTemperature csiTemperatureUnits = CSiProgram.eTemperature.NotApplicable;

            _callCode = _sapModel.GetDatabaseUnits_2(ref csiForceUnits, ref csiLengthUnits, ref csiTemperatureUnits);
            if (throwCurrentApiException(_callCode))
            {
                throw new CSiException(API_DEFAULT_ERROR_CODE);
            }

            forceUnits       = EnumLibrary.Convert(csiForceUnits, forceUnits);
            lengthUnits      = EnumLibrary.Convert(csiLengthUnits, lengthUnits);
            temperatureUnits = EnumLibrary.Convert(csiTemperatureUnits, temperatureUnits);
        }
Пример #16
0
    private eTemperature GetTempEnumFromValue(float value)
    {
        eTemperature t = eTemperature.Cold;

        if (value < 0.2f)
        {
            t = eTemperature.Hot;
        }
        else if (value < 0.4f)
        {
            t = eTemperature.Warm;
        }
        else if (value < 0.6f)
        {
            t = eTemperature.Normal;
        }
        else if (value < 0.8f)
        {
            t = eTemperature.Cool;
        }

        return(t);
    }
Пример #17
0
 /// Sets the Sea Level temperature, if it is to be different than the
 /// standard.
 /// This function will calculate a bias - a difference - from the standard
 /// atmosphere temperature and will apply that bias to the entire
 /// temperature profile. This is one way to set the temperature bias. Using
 /// the SetTemperatureBias function will replace the value calculated by
 /// this function.
 /// @param t the temperature value in the unit provided.
 /// @param unit the unit of the temperature.
 public override void SetTemperatureSL(double t, eTemperature unit = eTemperature.eFahrenheit)
 {
     SetTemperature(t, 0.0, unit);
 }
Пример #18
0
 // eTemperature
 internal static CSiProgram.eTemperature ToCSi(eTemperature enumValue)
 {
     return((CSiProgram.eTemperature)enumValue);
 }
Пример #19
0
 public override void SetTemperature(double t, double h, eTemperature unit = eTemperature.eFahrenheit)
 {
     throw new NotImplementedException("Pending upgrade to lastest version of JSBSIM");
 }
Пример #20
0
 /// Sets a Sea Level temperature delta that is ramped out by 86 km.
 /// The value of the delta is used to calculate a delta gradient that is
 /// applied to the temperature at all altitudes below 86 km (282152 ft).
 /// For instance, if a temperature of 20 degrees F is supplied, the delta
 /// gradient would be 20/282152 - or, about 7.09E-5 degrees/ft. At sea level,
 /// the full 20 degrees would be added to the standard temperature,
 /// but that 20 degree delta would be reduced by 7.09E-5 degrees for every
 /// foot of altitude above sea level, so that by 86 km, there would be no
 /// further delta added to the standard temperature.
 /// The graded delta can be used along with the a bias to tailor the
 /// temperature profile as desired.
 /// @param t the sea level temperature delta value in the unit provided.
 /// @param unit the unit of the temperature.
 public virtual void SetSLTemperatureGradedDelta(eTemperature unit, double deltemp)
 {
     SetTemperatureGradedDelta(deltemp, 0.0, unit);
 }
Пример #21
0
 /// Sets the Sea Level temperature.
 /// @param t the temperature value in the unit provided.
 /// @param unit the unit of the temperature.
 public virtual void SetTemperatureSL(double t, eTemperature unit = eTemperature.eFahrenheit)
 {
     SLtemperature = ConvertToRankine(t, unit);
 }
Пример #22
0
    private void PopulateTiles(ref IslandData data, Vector3 terrainPos, float[][] moisture, float[][] temps, float[,] heights, int size, ref TerrainData tData)
    {
        GameObject container = new GameObject();

        container.name = "Tile Colliders";
        container.transform.SetParent(_currentTerrain.transform);
        container.transform.position = Vector3.zero;
        GameObject tileObject    = null;
        Tile       t             = null;
        int        tilesPerMeter = 3;

        //int[] offsets = new int[] { 0, 4, 7, 10, 13, 16, 19 };
        //float[,,] splatData = new float[size, size, _terrainSplats.Length];

        float   subTileOffset  = 1 / (float)tilesPerMeter;
        Vector3 offsetPosition = new Vector3(0f, 0.05f, 0f);

        for (int i = 0; i < size; ++i)
        {
            for (int j = 0; j < size; ++j)
            {
                float height = heights[j, i];

                // don't put tiles on the bottom most layer
                if (height > 0f)
                {
                    int terrainX, terrainY;
                    GetWorldTerrainPosition(terrainPos, i, j, out terrainX, out terrainY);

                    GameObject tileContainer = new GameObject();
                    tileContainer.name = string.Format("Tile[{0},{1}]", i, j);
                    tileContainer.transform.SetParent(container.transform);
                    tileContainer.transform.position = Vector3.zero;

                    // for multiple tiles per meter
                    for (int k = 0; k < tilesPerMeter; ++k)
                    {
                        for (int l = 0; l < tilesPerMeter; ++l)
                        {
                            // create physical tile
                            offsetPosition.x = (subTileOffset / 2f) + subTileOffset * k;
                            offsetPosition.z = (subTileOffset / 2f) + subTileOffset * l;

                            tileObject      = (GameObject)Instantiate(_tilePrefab);
                            tileObject.name = string.Format("Sub Tile[{0},{1}]", k, l);
                            t = tileObject.AddComponent <Tile>();
                            t.Init(i, j, height, terrainX + offsetPosition.z, terrainY + offsetPosition.x);
                            tileObject.transform.position = t.WorldPosition;

                            // add to parent container for a neat hierarchy
                            tileObject.transform.SetParent(tileContainer.transform);
                        }
                    }

                    // determine biome
                    eMoisture    moist = GetMoistureEnumFromValue(moisture[i][j]);
                    eTemperature temp  = GetTempEnumFromValue(temps[i][j]);
                    eBiome       biome = _biomeTable[(int)moist, (int)temp];

                    t.SetBiomeFields(moist, temp, biome);

                    // set terrain texture
                    //int textureIndex = offsets[(int)biome] + (int)eTileType.Grass;
                    //splatData[j, i, textureIndex] = 1;
                }
                else
                {
                    // just dirt if height is zero
                    //int textureIndex = offsets[(int)eBiome.Jungle] + (int)eTileType.Dirt;
                    //splatData[j, i, textureIndex] = 1;
                }

                // need to fill the island data with values, even if no tile is actually created
                data.AddTile(t, i, j);
            }
        }

        //tData.SetAlphamaps(0, 0, splatData);
    }
Пример #23
0
 public void SetPresentUnits(eForce forceUnits,
                             eLength lengthUnits,
                             eTemperature temperatureUnits)
 {
 }
Пример #24
0
 /// Sets the temperature at the supplied altitude.
 /// @param t The temperature value in the unit provided.
 /// @param h The altitude in feet above sea level.
 /// @param unit The unit of the temperature.
 public abstract void SetTemperature(double t, double h, eTemperature unit = eTemperature.eFahrenheit);
Пример #25
0
 public void GetPresentUnits(ref eForce forceUnits,
                             ref eLength lengthUnits,
                             ref eTemperature temperatureUnits)
 {
     Assert.IsTrue(false);
 }
Пример #26
0
    public void PlaceTile(float x, float z, ref IslandData data, Vector3 terrainPos)
    {
        TerrainData tData = data.Data;

        float[,] heights = tData.GetHeights(0, 0, data.Size, data.Size);
        int     tilesPerMeter  = 3;
        float   subTileOffset  = 1 / (float)tilesPerMeter;
        Vector3 offsetPosition = new Vector3(0f, 0.05f, 0f);
        int     i = Mathf.RoundToInt(x);
        int     j = Mathf.RoundToInt(z);

        if (_tileContainer == null)
        {
            _tileContainer = new GameObject("Tile Container");
            _tileContainer.transform.SetParent(_currentTerrain.transform);
            _tileContainer.transform.localPosition = Vector3.zero;
        }

        float      height     = heights[j, i];
        GameObject tileObject = null;
        Tile       t          = null;

        // don't put tiles on the bottom most layer
        if (height > 0f)
        {
            int terrainX, terrainY;
            GetWorldTerrainPosition(terrainPos, i, j, out terrainX, out terrainY);

            // TODO this will need to be removed and only 1 tile be placed; not all 9

            //for multiple tiles per meter
            for (int k = 0; k < tilesPerMeter; ++k)
            {
                for (int l = 0; l < tilesPerMeter; ++l)
                {
                    // create physical tile
                    offsetPosition.x = (subTileOffset / 2f) + subTileOffset * k;
                    offsetPosition.z = (subTileOffset / 2f) + subTileOffset * l;

                    tileObject      = (GameObject)Instantiate(_tilePrefab);
                    tileObject.name = string.Format("Sub Tile[{0},{1}]", k, l);
                    t = tileObject.AddComponent <Tile>();
                    t.Init(i, j, height, terrainX + offsetPosition.z, terrainY + offsetPosition.x);
                    tileObject.transform.position = t.WorldPosition;

                    // add to parent container for a neat hierarchy
                    tileObject.transform.SetParent(_tileContainer.transform);
                }
            }

            // determine biome
            eMoisture    moist = eMoisture.Wet;       //GetMoistureEnumFromValue(moisture[i][j]);
            eTemperature temp  = eTemperature.Normal; //GetTempEnumFromValue(temps[i][j]);
            eBiome       biome = _biomeTable[(int)moist, (int)temp];

            t.SetBiomeFields(moist, temp, biome);

            // set terrain texture
            //int textureIndex = offsets[(int)biome] + (int)eTileType.Grass;
            //splatData[j, i, textureIndex] = 1;
        }
        else
        {
            // just dirt if height is zero
            //int textureIndex = offsets[(int)eBiome.Jungle] + (int)eTileType.Dirt;
            //splatData[j, i, textureIndex] = 1;
        }

        // need to fill the island data with values, even if no tile is actually created
        data.AddTile(t, i, j);
    }