⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 physicalrocket.java

📁 java设计模式源码
💻 JAVA
字号:
package com.oozinoz.firework;

/*
 * Copyright (c) 2001, 2005. Steven J. Metsker.
 * 
 * Steve Metsker makes no representations or warranties about
 * the fitness of this software for any particular purpose, 
 * including the implied warranty of merchantability.
 *
 * Please use this software as you wish with the sole
 * restriction that you may not claim that you wrote it.
 */

/**
 * A physical model of a rocket for use in simulations.
 */
public class PhysicalRocket {
    private double burnArea;
    private double burnRate;
    private double initialFuelMass;
    private double totalMass;

    private double totalBurnTime;

    private static double SPECIFIC_IMPULSE = 620; // Newtons/Kg
    private static double FUEL_DENSITY = 1800; // Kg/M**3

    public PhysicalRocket(double burnArea, double burnRate, double fuelMass, double totalMass) {
        this.burnArea = burnArea;
        this.burnRate = burnRate;
        this.initialFuelMass = fuelMass;
        this.totalMass = totalMass;

        double initialFuelVolume = fuelMass / FUEL_DENSITY;
        this.totalBurnTime = initialFuelVolume / (burnRate * burnArea);
    }

    /**
     * @return The remaining mass of the rocket after burning off a portion of
     *         its fuel.
     * @param time time since ignition
     */
    public double getMass(double t) {
        if (t > totalBurnTime) return totalMass - initialFuelMass;
        double burntFuelVolume = burnRate * burnArea * t;
        return totalMass - burntFuelVolume * FUEL_DENSITY;
    }

    /**
     * @param time time since ignition
     * @return Calculated thrust with the standard Oozinoz formula.
     */
    public double getThrust(double time) {
        if (time > totalBurnTime) return 0;
        return FUEL_DENSITY * SPECIFIC_IMPULSE * burnRate * burnArea;
    }

    /**
     * @return the time this rocket's fuel burns.
     */
    public double getBurnTime() {
        return totalBurnTime;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -