/// <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);
        }
        /// <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));
        }
Exemplo n.º 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));
        }
        /// <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);
        }
Exemplo n.º 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));
        }
        /// <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);
        }
        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);
        }
        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);
        }
        /// <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));
        }
        /// <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);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="calculators"></param>
 public TrajectoryCalculator(ITrajectoryParameters parameters,
                             params ITrajectoryComponentCalculator[] calculators)
     : this(calculators)
 {
     _parameters = parameters;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="calculators"></param>
 public TrajectoryCalculator(ITrajectoryParameters parameters,
     params ITrajectoryComponentCalculator[] calculators)
     : this(calculators)
 {
     _parameters = parameters;
 }
Exemplo n.º 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);
Exemplo n.º 14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 public BasicTrajectoryCalculator(ITrajectoryParameters parameters)
     : this()
 {
     Parameters = parameters;
 }
 /// <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);
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="parameters"></param>
 public BasicTrajectoryCalculator(ITrajectoryParameters parameters)
     : this()
 {
     Parameters = parameters;
 }
 /// <summary>
 /// Calculates the drag force given the <paramref name="parameters"/>.
 /// </summary>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public abstract IQuantity Calculate(ITrajectoryParameters parameters);
Exemplo n.º 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);