Esempio n. 1
0
        public void TestTable(DragTableId id)
        {
            DragTable table = DragTable.Get(id);

            for (int i = 0; i < table.Count; i++)
            {
                var dataPoint = table[i];
                ((Action)(() => TestDataPoint(dataPoint, table))).Should().NotThrow();
            }
        }
Esempio n. 2
0
        public void TestTable(DragTableId id)
        {
            DragTable table = DragTable.Get(id);

            for (int i = 0; i < table.Count; i++)
            {
                var dataPoint = table[i];
                TestDataPoint(dataPoint, table);
            }
        }
Esempio n. 3
0
        public void CustomTable()
        {
            TableLoader  template = TableLoader.FromResource("g1_nowind");
            const double velocityAccuracyInPercent = 0.005, dropAccuracyInMOA = 0.2, windageAccuracyInMOA = 0.2;

            var table = DragTable.Get(template.Ammunition.BallisticCoefficient.Table);

            template.Ammunition.BallisticCoefficient = new BallisticCoefficient(template.Ammunition.BallisticCoefficient.Value, DragTableId.GC);


            var cal = new TrajectoryCalculator();

            ShotParameters shot = new ShotParameters()
            {
                Step            = new Measurement <DistanceUnit>(50, DistanceUnit.Yard),
                MaximumDistance = new Measurement <DistanceUnit>(1000, DistanceUnit.Yard),
                SightAngle      = cal.SightAngle(template.Ammunition, template.Rifle, template.Atmosphere, table),
                ShotAngle       = template.ShotParameters?.ShotAngle,
                CantAngle       = template.ShotParameters?.CantAngle,
            };

            var trajectory = cal.Calculate(template.Ammunition, template.Rifle, template.Atmosphere, shot, null, table);

            trajectory.Length.Should().Be(template.Trajectory.Count);

            for (int i = 0; i < trajectory.Length; i++)
            {
                var point         = trajectory[i];
                var templatePoint = template.Trajectory[i];

                point.Distance.In(templatePoint.Distance.Unit).Should().BeApproximately(templatePoint.Distance.Value, templatePoint.Distance.Value * velocityAccuracyInPercent, $"@{point.Distance:N0}");
                point.Velocity.In(templatePoint.Velocity.Unit).Should().BeApproximately(templatePoint.Velocity.Value, templatePoint.Velocity.Value * velocityAccuracyInPercent, $"@{point.Distance:N0}");

                var dropAccuracyInInch = Measurement <AngularUnit> .Convert(dropAccuracyInMOA, AngularUnit.MOA, AngularUnit.InchesPer100Yards) * templatePoint.Distance.In(DistanceUnit.Yard) / 100;

                var windageAccuracyInInch = Measurement <AngularUnit> .Convert(windageAccuracyInMOA, AngularUnit.MOA, AngularUnit.InchesPer100Yards) * templatePoint.Distance.In(DistanceUnit.Yard) / 100;

                point.Drop.In(DistanceUnit.Inch).Should().BeApproximately(templatePoint.Drop.In(DistanceUnit.Inch), dropAccuracyInInch, $"@{point.Distance:N0}");
                point.Windage.In(DistanceUnit.Inch).Should().BeApproximately(templatePoint.Windage.In(DistanceUnit.Inch), windageAccuracyInInch, $"@{point.Distance:N0}");
            }
        }