public void Tan(double value, AngularUnit unit, double expected)
        {
            var v = new Measurement <AngularUnit>(value, unit);

            MeasurementMath.Tan(v).Should().BeApproximately(expected, 1e-10);
            MeasurementMath.Atan(expected).In(unit).Should().BeApproximately(value, 1e-7);
        }
        public TrajectoryPoint(TimeSpan time, Measurement <DistanceUnit> distance,
                               Measurement <VelocityUnit> velocity, double mach, Measurement <DistanceUnit> drop,
                               Measurement <DistanceUnit> windage, Measurement <EnergyUnit> energy,
                               Measurement <WeightUnit> optimalGameWeight)
        {
            Time           = time;
            Distance       = distance;
            Velocity       = velocity;
            Drop           = drop;
            DropAdjustment = MeasurementMath.Atan(Drop / Distance);
            Mach           = mach;

            Windage           = windage;
            WindageAdjustment = MeasurementMath.Atan(Windage / Distance);
            Energy            = energy;
            OptimalGameWeight = optimalGameWeight;
        }
Esempio n. 3
0
        /// <summary>
        /// <para>Draws a square target on the specified canvas</para>
        /// <para>Use this method before drawing the reticle</para>
        /// </summary>
        /// <param name="trajectory">The trajectory to get the BDC parameters</param>
        /// <param name="targetSize">The size of a side of a rectangular target</param>
        /// <param name="targetDistance">The distance to the target</param>
        /// <param name="color">The color of the target</param>
        public void DrawTarget(IEnumerable <TrajectoryPoint> trajectory,
                               Measurement <DistanceUnit> targetSize, Measurement <DistanceUnit> targetDistance,
                               string color)
        {
            var angularTargetSize = MeasurementMath.Atan(targetSize / targetDistance);
            var trajectoryPoint   = FindByDistance(trajectory, targetDistance);

            if (trajectoryPoint != null)
            {
                var centerY = trajectoryPoint.DropAdjustment;
                var centerX = trajectoryPoint.WindageAdjustment;
                var x0      = centerX - angularTargetSize / 2;
                var y0      = centerY + angularTargetSize / 2;

                DrawElement(new ReticleRectangle()
                {
                    TopLeft = new ReticlePosition(x0, y0),
                    Size    = new ReticlePosition(angularTargetSize, angularTargetSize),
                    Fill    = false,
                    Color   = color,
                });
            }
        }