Esempio n. 1
0
        /// <summary>
        /// 7. Constructor for a projectile motion Quantities. Computes an elevation angle based on the length.
        /// </summary>
        /// <param name="v">An initial velocity.</param>
        /// <param name="l">The length.</param>
        /// <param name="h">An initial height.</param>
        /// <param name="g">A gravitation acceleration of the planet.</param>
        /// <param name="units">The units of Quantities. By default metre per second, radian, metre and metre per square second.</param>
        public ProjectileMotionQuantities(Length l, InitialVelocity v, InitialHeight h, GravAcceleration g, ProjectileMotionResultsUnits units = null)
        {
            Units = units ?? new ProjectileMotionResultsUnits();

            V = v;
            H = h;
            G = g;
            Α = new ElevationAngle(
                GetResultWithComputeExpection(
                    l.GetBasicVal() == 0 && H.GetBasicVal() == 0 ?
                    double.NaN
                        :
                    EquationSolver.BisectionFindRoot(
                        a => V.GetBasicVal() * Math.Cos(a) * (
                            V.GetBasicVal() * Math.Sin(a) + Math.Sqrt(Math.Pow(V.GetBasicVal() *
                                                                               Math.Sin(a), 2) + 2.0 * G.GetBasicVal() * H.GetBasicVal())
                            ) / G.GetBasicVal() - l.GetBasicVal(),
                        0,
                        new ElevationAngle(ElevationAngle.ElevationAngleTypes.Right).Val,
                        1E-4
                        )
                    ),
                UnitAngle.Basic
                ).Convert(Units.Angle);

            UsedAssignmentType = AssignmentsTypes.ElevationAngleByLength;
        }
Esempio n. 2
0
        /// <summary>
        /// 3. Constructor for a projectile motion Quantities. Computes an initial velocity based on the duration.
        /// </summary>
        /// <param name="α">An elevation angle.</param>
        /// <param name="dur">The duration.</param>
        /// <param name="h">An initial height.</param>
        /// <param name="g">A gravitation acceleration of the planet.</param>
        /// <param name="units">The units of Quantities. By default metre per second, radian, metre and metre per square second.</param>
        public ProjectileMotionQuantities(Duration dur, ElevationAngle α, InitialHeight h, GravAcceleration g, ProjectileMotionResultsUnits units = null)
        {
            Units = units ?? new ProjectileMotionResultsUnits();

            Α = α;
            H = h;
            G = g;

            V = new InitialVelocity(
                GetResultWithComputeExpection(
                    dur.GetBasicVal() == 0 && H.GetBasicVal() == 0
                        ? 0
                        :
                    (Math.Pow(dur.GetBasicVal(), 2.0) * G.GetBasicVal() - 2 * H.GetBasicVal()) /
                    (2.0 * Math.Sin(Α.GetBasicVal()) * dur.GetBasicVal())
                    ),
                UnitVelocity.Basic).Convert(Units.Velocity);

            UsedAssignmentType = AssignmentsTypes.InitialVelocityByDuration;
        }
Esempio n. 3
0
        /// <summary>
        /// 2. Constructor for a projectile motion Quantities. Computes an elevation angle based on the duration.
        /// </summary>
        /// <param name="v">An initial velocity.</param>
        /// <param name="dur">The duration.</param>
        /// <param name="h">An initial height.</param>
        /// <param name="g">A gravitation acceleration of the planet.</param>
        /// <param name="units">The units of Quantities. By default metre per second, radian, metre and metre per square second.</param>
        public ProjectileMotionQuantities(Duration dur, InitialVelocity v, InitialHeight h, GravAcceleration g, ProjectileMotionResultsUnits units = null)
        {
            Units = units ?? new ProjectileMotionResultsUnits();

            V = v;
            H = h;
            G = g;
            Α = new ElevationAngle(
                GetResultWithComputeExpection(
                    V.GetBasicVal() > 0 && H.GetBasicVal() == 0 && dur.GetBasicVal() == 0
                        ? 0
                        :
                    Math.Asin(
                        (Math.Pow(dur.GetBasicVal(), 2.0) * G.GetBasicVal() - 2 * H.GetBasicVal()) /
                        (2.0 * V.GetBasicVal() * dur.GetBasicVal())
                        )
                    ),
                UnitAngle.Basic).Convert(Units.Angle);

            UsedAssignmentType = AssignmentsTypes.ElevationAngleByDuration;
        }
Esempio n. 4
0
        /// <summary>
        /// 11. Constructor for a projectile motion Quantities. Computes an elevation angle for motion with maximum range.
        /// </summary>
        /// <param name="v">An initial velocity.</param>
        /// <param name="h">An initial height.</param>
        /// <param name="g">A gravitation acceleration of the planet.</param>
        /// <param name="units">The units of Quantities. By default metre per second, radian, metre and metre per square second.</param>
        public ProjectileMotionQuantities(InitialVelocity v, InitialHeight h, GravAcceleration g, ProjectileMotionResultsUnits units = null)
        {
            Units = units ?? new ProjectileMotionResultsUnits();

            V = v;
            H = h;
            G = g;
            Α = new ElevationAngle(
                GetResultWithComputeExpection(
                    Math.Acos(
                        Math.Sqrt(
                            (2.0 * G.GetBasicVal() * H.GetBasicVal() + Math.Pow(V.GetBasicVal(), 2.0)) /
                            (2.0 * G.GetBasicVal() * H.GetBasicVal() + 2.0 * Math.Pow(V.GetBasicVal(), 2.0))
                            )
                        )
                    ),
                UnitAngle.Basic
                ).Convert(Units.Angle);

            UsedAssignmentType = AssignmentsTypes.ElevationAngleGetMaxRange;
        }
Esempio n. 5
0
        /// <summary>
        /// 10. Constructor for a projectile motion Quantities. Computes an elevation angle based on the maximal height.
        /// </summary>
        /// <param name="v">An initial velocity.</param>
        /// <param name="dur">The maximal height.</param>
        /// <param name="h">An initial height.</param>
        /// <param name="g">A gravitation acceleration of the planet.</param>
        /// <param name="units">The units of Quantities. By default metre per second, radian, metre and metre per square second.</param>
        public ProjectileMotionQuantities(MaximalHeight maxHeight, InitialVelocity v, InitialHeight h, GravAcceleration g, ProjectileMotionResultsUnits units = null)
        {
            Units = units ?? new ProjectileMotionResultsUnits();

            V = v;
            H = h;
            G = g;
            Α = new ElevationAngle(
                GetResultWithComputeExpection(
                    maxHeight.GetBasicVal() == 0 && H.GetBasicVal() == 0 ?
                    double.NaN
                        :
                    Math.Asin(Math.Sqrt(
                                  2.0 * G.GetBasicVal() * (maxHeight.GetBasicVal() - H.GetBasicVal()) /
                                  Math.Pow(V.GetBasicVal(), 2)
                                  ))
                    ),
                UnitAngle.Basic
                ).Convert(Units.Angle);

            UsedAssignmentType = AssignmentsTypes.ElevationAngleByMaxHeight;
        }
Esempio n. 6
0
        /// <summary>
        /// 8. Constructor for a projectile motion Quantities. Computes an initial velocity based on the maximal height.
        /// </summary>
        /// <param name="α">An elevation angle.</param>
        /// <param name="maxHeight">The maximal height.</param>
        /// <param name="h">An initial height.</param>
        /// <param name="g">A gravitation acceleration of the planet.</param>
        /// <param name="units">The units of Quantities. By default metre per second, radian, metre and metre per square second.</param>
        public ProjectileMotionQuantities(MaximalHeight maxHeight, ElevationAngle α, InitialHeight h, GravAcceleration g, ProjectileMotionResultsUnits units = null)
        {
            Units = units ?? new ProjectileMotionResultsUnits();

            Α = α;
            H = h;
            G = g;
            V = new InitialVelocity(
                GetResultWithComputeExpection(
                    maxHeight.GetBasicVal() == 0 && H.GetBasicVal() == 0 ?
                    Α.GetBasicVal() == 0 ?
                    double.NaN : 0
                        :
                    Math.Sqrt(
                        2.0 * G.GetBasicVal() * (maxHeight.GetBasicVal() - H.GetBasicVal()) /
                        Math.Pow(Math.Sin(Α.GetBasicVal()), 2.0)
                        )
                    ),
                UnitVelocity.Basic
                ).Convert(Units.Velocity);

            UsedAssignmentType = AssignmentsTypes.InitialVelocityByMaxHeight;
        }
Esempio n. 7
0
        /// <summary>
        /// 6. Constructor for a projectile motion Quantities. Computes an initial velocity based on the length.
        /// </summary>
        /// <param name="α">An elevation angle.</param>
        /// <param name="l">The length.</param>
        /// <param name="h">An initial height.</param>
        /// <param name="g">A gravitation acceleration of the planet.</param>
        /// <param name="units">The units of Quantities. By default metre per second, radian, metre and metre per square second.</param>
        public ProjectileMotionQuantities(Length l, ElevationAngle α, InitialHeight h, GravAcceleration g, ProjectileMotionResultsUnits units = null)
        {
            Units = units ?? new ProjectileMotionResultsUnits();

            Α = α;
            H = h;
            G = g;
            V = new InitialVelocity(
                GetResultWithComputeExpection(
                    Α.IsRight() ?
                    double.NaN
                        :
                    l.GetBasicVal() == 0 && H.GetBasicVal() == 0 && Α.GetBasicVal() > 0 ? 0 :
                    l.GetBasicVal() * Math.Sqrt(G.GetBasicVal() / Math.Cos(Α.GetBasicVal())) /
                    Math.Sqrt(
                        2.0 * l.GetBasicVal() * Math.Sin(Α.GetBasicVal()) +
                        2.0 * H.GetBasicVal() * Math.Cos(Α.GetBasicVal())
                        )
                    ),
                UnitVelocity.Basic
                ).Convert(Units.Velocity);

            UsedAssignmentType = AssignmentsTypes.InitialVelocityByLength;
        }
        public void TestCorrectResultsMotionWithResistanceRight()
        {
            ProjectileMotionWithResistance motionRight = new ProjectileMotionWithResistance(
                new ProjectileMotionWithResistanceSettings(
                    new ProjectileMotionWithResistanceQuantities(V,
                                                                 new ElevationAngle(ElevationAngle.ElevationAngleTypes.Right),
                                                                 H, G, M, Ρ, A, C, Utilities.UnitsOfResults)
                    )
            {
                PointsForTrajectory = UsePoints
            }
                );

            Utilities.AlmostSame(motionRight.GetLength(), new Length(0, UnitLength.Basic));
            Utilities.AlmostSame(motionRight.GetMaxDistance(), new Length(motionRight.GetMaxHeight().GetBasicVal() - H.GetBasicVal(), UnitLength.Basic));
            Utilities.AlmostSame(motionRight.GetMaxDistance(), motionRight.Trajectory.GetInitialPoint().GetDistanceFromPoint(motionRight.Trajectory.GetHighestPoint()));
            Utilities.AlmostSame(motionRight.Trajectory.GetArcLength(), new Length(2 * motionRight.GetMaxHeight().GetBasicVal() - H.GetBasicVal(), UnitLength.Basic));
            Utilities.AlmostSame(motionRight.Trajectory.GetAreaUnderArc(), new Area(0, UnitArea.Basic));
            Utilities.AlmostSame(motionRight.Trajectory.GetHighestPoint().Y, motionRight.GetMaxHeight());
            Utilities.AlmostSame(motionRight.Trajectory.GetFarthestPoint().Y, motionRight.Trajectory.GetHighestPoint().Y);
            Utilities.AlmostSame(motionRight.Trajectory.GetFarthestPoint().X, motionRight.Trajectory.GetHighestPoint().X);
            Utilities.AlmostSame(motionRight.Trajectory.GetInitialPoint().X, motionRight.Trajectory.GetFinalPoint().X);
            Utilities.AlmostSame(motionRight.Trajectory.GetInitialPoint().Y, new Length(motionRight.Trajectory.GetFinalPoint().Y.GetBasicVal() + H.GetBasicVal(), UnitLength.Basic));

            Utilities.AlmostSame(Utilities.GetTrajectoryLengthIteratively(motionRight), motionRight.Trajectory.GetArcLength());
            Utilities.AlmostSame(Utilities.GetAreaUnderTrajectoryIteratively(motionRight), motionRight.Trajectory.GetAreaUnderArc());
            Utilities.AlmostSame(Utilities.GetMaxHeightIteratively(motionRight), motionRight.GetMaxHeight());
            Utilities.AlmostSame(Utilities.GetMaxDistanceIteratively(motionRight), motionRight.GetMaxDistance());
        }