コード例 #1
0
        /// <summary>
        /// Calculates the <see cref="TrajectoryComponent.MaxHeight"/> component. Effectively
        /// ignores the <paramref name="timeQty"/> part, for purposes of this component.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, V.MetersPerSecond);

            var g = Values.G;

            // http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html#tra5
            var resultQty = (Quantity) ivv.Squared()/((Quantity) g*2d);

            return VerifyDimensions(resultQty, L.Meter);
        }
コード例 #2
0
        /// <summary>
        /// Calculates the <see cref="TrajectoryComponent.MaxHeight"/> component. Effectively
        /// ignores the <paramref name="timeQty"/> part, for purposes of this component.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, V.MetersPerSecond);

            var g = Values.G;

            // http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html#tra5
            var resultQty = (Quantity)ivv.Squared() / ((Quantity)g * 2d);

            return(VerifyDimensions(resultQty, L.Meter));
        }
コード例 #3
0
        /// <summary>
        /// Calculates the <see cref="TrajectoryComponent.MaxTime"/> component. Effectively
        /// ignores the <paramref name="timeQty"/> part, for purposes of this component.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            // ReSharper disable once InvertIf
            if (ReferenceEquals(null, _componentQty))
            {
                var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, V.MetersPerSecond);
                var vla = VerifyDimensions(parameters.VerticalLaunchAngleQty, Theta.Radian);

                var g = Values.G;

                _componentQty = (2d * (Quantity)ivv * vla.Sin()) / g;
            }

            return(VerifyDimensions(_componentQty, T.Second));
        }
コード例 #4
0
        /// <summary>
        /// Calculates the <see cref="TrajectoryComponent.MaxTime"/> component. Effectively
        /// ignores the <paramref name="timeQty"/> part, for purposes of this component.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            // ReSharper disable once InvertIf
            if (ReferenceEquals(null, _componentQty))
            {
                var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, V.MetersPerSecond);
                var vla = VerifyDimensions(parameters.VerticalLaunchAngleQty, Theta.Radian);

                var g = Values.G;

                _componentQty = (2d*(Quantity) ivv*vla.Sin())/g;
            }

            return VerifyDimensions(_componentQty, T.Second);
        }
コード例 #5
0
        /// <summary>
        /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var m = L.Meter;
            var s = T.Second;

            var t = VerifyDimensions(timeQty, s);

            var ihv = VerifyDimensions(parameters.InitialHorizontalVelocityQty, m, s.Invert());

            /* x = ( V cos A ) t
             * Ditto re: vertical component calculations: we already have initial horizontal velocity ready.
             * This calculation intentionally ignores Forces due to aerodynamic drag. */
            var resultQty = (Quantity)ihv * t;

            // Should be left with a Length dimension.
            return(VerifyDimensions(resultQty, m));
        }
コード例 #6
0
        /// <summary>
        /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var m = L.Meter;
            var s = T.Second;

            var t = VerifyDimensions(timeQty, s);

            var ihv = VerifyDimensions(parameters.InitialHorizontalVelocityQty, m, s.Invert());

            /* x = ( V cos A ) t
             * Ditto re: vertical component calculations: we already have initial horizontal velocity ready.
             * This calculation intentionally ignores Forces due to aerodynamic drag. */
            var resultQty = (Quantity) ihv*t;

            // Should be left with a Length dimension.
            return VerifyDimensions(resultQty, m);
        }
コード例 #7
0
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            // ReSharper disable once InvertIf
            if (ReferenceEquals(null, _componentQty))
            {
                var iv = VerifyDimensions(parameters.InitialVelocityQty, V.MetersPerSecond);
                var vla = VerifyDimensions(parameters.VerticalLaunchAngleQty, Theta.Radian);

                var g = Values.G;

                //TODO: also does not take into consideration the initial launch height, i.e. from which thrown, punted, etc.

                // Also, leverages trig identity: sin( 2 Θ ) = 2 sin( Θ ) cos( Θ )
                _componentQty = ((Quantity) iv.Squared()*((Quantity) vla*2d).Sin())/g;
            }

            return VerifyDimensions(_componentQty, L.Meter);
        }
コード例 #8
0
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            // ReSharper disable once InvertIf
            if (ReferenceEquals(null, _componentQty))
            {
                var iv = VerifyDimensions(parameters.InitialVelocityQty, V.MetersPerSecond);
                var vla = VerifyDimensions(parameters.VerticalLaunchAngleQty, Theta.Radian);

                var g = Values.G;

                //TODO: also does not take into consideration the initial launch height, i.e. from which thrown, punted, etc.

                // Also, leverages trig identity: sin( 2 Θ ) = 2 sin( Θ ) cos( Θ )
                _componentQty = ((Quantity) iv.Squared()*((Quantity) vla*2d).Sin())/g;
            }

            return VerifyDimensions(_componentQty, L.Meter);
        }
コード例 #9
0
        /// <summary>
        /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var m = L.Meter;
            var s = T.Second;

            var t = VerifyDimensions(timeQty, s);

            var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, m, s.Invert());

            // TODO: TBD: Forces due to aerodynamic lift must also play a role here, but not in this "simple" component calculator...
            var g = VerifyDimensions(Values.StandardGravity, m, s.Squared().Invert());

            /* y = ( V sin A ) t - g t^2 / 2
             * Or in this case, we have already calculated the initial vertical velocity component.
             * ref: http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html#tra12 */
            var resultQty = (Quantity)ivv * t - ((Quantity)g * t.Squared()) / 2d;

            // Should be left with a Length dimension.
            return(VerifyDimensions(resultQty, m));
        }
コード例 #10
0
        /// <summary>
        /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="timeQty"></param>
        /// <returns></returns>
        public override IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty)
        {
            var m = L.Meter;
            var s = T.Second;

            var t = VerifyDimensions(timeQty, s);

            var ivv = VerifyDimensions(parameters.InitialVerticalVelocityQty, m, s.Invert());

            // TODO: TBD: Forces due to aerodynamic lift must also play a role here, but not in this "simple" component calculator...
            var g = VerifyDimensions(Values.StandardGravity, m, s.Squared().Invert());

            /* y = ( V sin A ) t - g t^2 / 2
             * Or in this case, we have already calculated the initial vertical velocity component.
             * ref: http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html#tra12 */
            var resultQty = (Quantity) ivv*t - ((Quantity) g*t.Squared())/2d;

            // Should be left with a Length dimension.
            return VerifyDimensions(resultQty, m);
        }
コード例 #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="calculators"></param>
 public TrajectoryCalculator(ITrajectoryParameters parameters,
                             params ITrajectoryComponentCalculator[] calculators)
     : this(calculators)
 {
     _parameters = parameters;
 }
コード例 #12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="calculators"></param>
 public TrajectoryCalculator(ITrajectoryParameters parameters,
     params ITrajectoryComponentCalculator[] calculators)
     : this(calculators)
 {
     _parameters = parameters;
 }
コード例 #13
0
 /// <summary>
 /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="timeQty"></param>
 /// <returns></returns>
 public abstract IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty);
コード例 #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 public BasicTrajectoryCalculator(ITrajectoryParameters parameters)
     : this()
 {
     Parameters = parameters;
 }
コード例 #15
0
 /// <summary>
 /// Calculates a trajectory component given <paramref name="parameters"/> and <paramref name="timeQty"/>.
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="timeQty"></param>
 /// <returns></returns>
 public abstract IQuantity Calculate(ITrajectoryParameters parameters, IQuantity timeQty);
コード例 #16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 public BasicTrajectoryCalculator(ITrajectoryParameters parameters)
     : this()
 {
     Parameters = parameters;
 }
コード例 #17
0
 /// <summary>
 /// Calculates the drag force given the <paramref name="parameters"/>.
 /// </summary>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public abstract IQuantity Calculate(ITrajectoryParameters parameters);
コード例 #18
0
 /// <summary>
 /// Calculates the drag force given the <paramref name="parameters"/>.
 /// </summary>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public abstract IQuantity Calculate(ITrajectoryParameters parameters);