Пример #1
0
        public Move ComputeMove(Position dest)
        {
            var move = new Move
            {
                Pos = new Position
                {
                    X = dest.X - this.Speed.Vx,
                    Y = dest.Y - this.Speed.Vy
                }
            };

            // Acc
            var dist = this.Pos.Dist(move.Pos);

            if (Math.Abs(dist) <= 0.0001)
            {
                return(move);
            }

            //var expectedVx = Math.Abs(move.Pos.X - this.Pos.X) / (1 - this.Friction);
            //var expectedVy = Math.Abs(move.Pos.Y - this.Pos.Y) / (1 - this.Friction);

            //var accX = (int)Math.Round(expectedVx * dist * this.Mass);
            //var accY = (int)Math.Round(expectedVy * dist * this.Mass);

            //Program.ConsoleHelper.Debug($"accX={accX}|accY={accY}");
            //move.Acc = Math.Min((accX + accY) / 2, 300);

            var acc = (int)Math.Round(this.Mass * dist);

            move.Acc = Math.Min(acc, 300);
            return(move);
        }
Пример #2
0
        public static List <Vector3Int> MakeLine(Vector3Int pos1, Vector3Int pos2)
        {
            List <Vector3Int> affected = new List <Vector3Int>();
            bool notdrawn = true;

            int x1   = pos1.x;
            int y1   = pos1.x;
            int z1   = pos1.x;
            int x2   = pos2.x;
            int y2   = pos2.y;
            int z2   = pos2.z;
            int tipx = x1;
            int tipy = y1;
            int tipz = z1;
            int dx   = Math.Abs(x2 - x1);
            int dy   = Math.Abs(y2 - y1);
            int dz   = Math.Abs(z2 - z1);

            if (dx + dy + dz == 0)
            {
                affected.Add(pos2 + new Vector3Int(tipx, tipy, tipz));
                notdrawn = false;
            }

            if (Math.Max(Math.Max(dx, dy), dz) == dx && notdrawn)
            {
                for (int domstep = 0; domstep <= dx; domstep++)
                {
                    tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
                    tipy = (int)Math.Round(y1 + domstep * (((double)dy) / ((double)dx)) * (y2 - y1 > 0 ? 1 : -1));
                    tipz = (int)Math.Round(z1 + domstep * (((double)dz) / ((double)dx)) * (z2 - z1 > 0 ? 1 : -1));
                    affected.Add(new Vector3Int(tipx, tipy, tipz));
                }
                notdrawn = false;
            }

            if (Math.Max(Math.Max(dx, dy), dz) == dy && notdrawn)
            {
                for (int domstep = 0; domstep <= dx; domstep++)
                {
                    tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
                    tipy = (int)Math.Round(y1 + domstep * ((double)dy) / ((double)dx) * (y2 - y1 > 0 ? 1 : -1));
                    tipz = (int)Math.Round(z1 + domstep * ((double)dz) / ((double)dx) * (z2 - z1 > 0 ? 1 : -1));
                    affected.Add(new Vector3Int(tipx, tipy, tipz));
                }
                notdrawn = false;
            }

            if (Math.Max(Math.Max(dx, dy), dz) == dz && notdrawn)
            {
                for (int domstep = 0; domstep <= dz; domstep++)
                {
                    tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
                    tipy = (int)Math.Round(y1 + domstep * ((double)dy) / ((double)dz) * (y2 - y1 > 0 ? 1 : -1));
                    tipx = (int)Math.Round(x1 + domstep * ((double)dx) / ((double)dz) * (x2 - x1 > 0 ? 1 : -1));
                    affected.Add(pos2 + new Vector3Int(tipx, tipy, tipz));
                }
            }
            return(affected);
        }
        public Task <QuotationResult> CalculatePremiums(QuotationInput quoteparams)
        {
            try
            {
                return(Task.Run(() =>
                {
                    double d1 = 0.0;
                    double d2 = 0.0;
                    QuotationResult quotes = new QuotationResult();
                    double S = double.Parse(quoteparams.StockPrice.Replace(".", ","));
                    double K = double.Parse(quoteparams.StrikePrice.Replace(".", ","));
                    double T = double.Parse(quoteparams.TimeToMaturity.Replace(".", ","));
                    double r = double.Parse(quoteparams.InterestRate.Replace(".", ","));
                    double v = double.Parse(quoteparams.Volatility.Replace(".", ","));

                    d1 = Math.Round((Math.Log(S / K) + (r + v * v / 2.0) * T) / v / Math.Sqrt(T), 4);
                    d2 = Math.Round(d1 - v * Math.Sqrt(T), 4);

                    quotes.D1 = d1;
                    quotes.D2 = d2;

                    quotes.CallPremium = Math.Round(S * CumulativeNormDistFunction(d1) - K * Math.Exp(-r * T) * CumulativeNormDistFunction(d2), 4);
                    quotes.PutPremium = Math.Round(K * Math.Exp(-r * T) * CumulativeNormDistFunction(-d2) - S * CumulativeNormDistFunction(-d1), 4);

                    return quotes;
                }));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Пример #4
0
    // Requires FM map open
    public static FlightMaster GetBestAlternativeTo(List <string> reachableTaxis)
    {
        float        num      = ObjectManager.Me.Position.DistanceTo(destinationVector);
        FlightMaster resultFM = null;

        // Pre order the list
        List <FlightMaster> orderedListFM = FlightMasterDB.FlightMasterList
                                            .FindAll(fm => reachableTaxis.Contains(fm.Name))
                                            .OrderBy(fm => fm.Position.DistanceTo(destinationVector)).ToList();

        foreach (FlightMaster flightMaster in orderedListFM)
        {
            if (flightMaster.Position.DistanceTo(destinationVector) < num)
            {
                float realDist = ToolBox.CalculatePathTotalDistance(flightMaster.Position, destinationVector);
                Logger.Log($"[TO2] {flightMaster.Name} is {Math.Round(realDist)} yards away from destination");
                if (realDist < num)
                {
                    num      = realDist;
                    resultFM = flightMaster;
                }
            }
        }
        return(resultFM);
    }
Пример #5
0
    void Update()
    {
        var deviceR = SteamVR_Controller.Input((int)controllerR.index);

        if (deviceR.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            init = deviceR.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
        }

        else if (deviceR.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
        {
            final = deviceR.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;

            double disp = final - init;
            n2 = n + (int)Math.Round(3 * disp);

            if (n2 >= 3)
            {
                polygon.GetComponent <MeshFilter>().mesh = PolyGen(n2, 0.06);
            }
        }

        else if (deviceR.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            if (n2 != n && n2 >= 3)
            {
                n = n2;
                towerGen.BuildTower(n);
            }
            init = 0;
        }
    }
Пример #6
0
    public static FlightMaster GetClosestFlightMasterFrom(float maxRadius)
    {
        FlightMaster result = null;

        // Pre order the list
        List <FlightMaster> orderedListFM = FlightMasterDB.FlightMasterList
                                            .FindAll(fm => (fm.IsDiscovered || WFMSettings.CurrentSettings.TakeUndiscoveredTaxi) &&
                                                     ToolBox.FMIsOnMyContinent(fm) &&
                                                     !fm.IsDisabledByPlugin())
                                            .OrderBy(fm => fm.Position.DistanceTo(ObjectManager.Me.Position)).ToList();

        foreach (FlightMaster flightMaster in orderedListFM)
        {
            if (flightMaster.Position.DistanceTo(ObjectManager.Me.Position) < maxRadius)
            {
                float realDist = ToolBox.CalculatePathTotalDistance(ObjectManager.Me.Position, flightMaster.Position);
                Logger.Log($"[FROM] {flightMaster.Name} is {Math.Round(realDist)} yards away");
                if (realDist < maxRadius)
                {
                    maxRadius = realDist;
                    result    = flightMaster;
                }
            }
        }
        return(result);
    }
Пример #7
0
        public void ExecuteCommand911(IRocketPlayer caller, string[] parameters)
        {
            if (parameters.Length < 1)
            {
                UnturnedChat.Say(caller, "Usage: /emergency <message>", Color.yellow);
                return;
            }

            string msg = string.Join(" ", parameters);

            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (!emergencies.ContainsKey(player.CSteamID))
            {
                emergencies.Add(player.CSteamID, DateTime.Now);
            }
            foreach (SteamPlayer sp in Provider.clients)
            {
                UnturnedPlayer tmpPlayer = UnturnedPlayer.FromSteamPlayer(sp);
                if ((tmpPlayer.HasPermission("emergency.receive") && !silent.Contains(tmpPlayer.CSteamID)) || tmpPlayer.CSteamID == player.CSteamID)
                {
                    if (Configuration.Instance.ShowCoordinates)
                    {
                        string x = Math.Round(player.Position.x).ToString();
                        string y = Math.Round(player.Position.y).ToString();
                        string z = Math.Round(player.Position.z).ToString();
                        UnturnedChat.Say(tmpPlayer, Translate("emergencycoords", player.CharacterName, msg, x, y, z), Color.red);
                    }
                    else
                    {
                        UnturnedChat.Say(tmpPlayer, Translate("emergency", player.CharacterName, msg), Color.red);
                    }
                }
            }
        }
Пример #8
0
        private void UpdateDragging(MotionEvent ev)
        {
            SetHotspot(ev.GetX(), ev.GetY());
            int  x          = (int)ev.GetX();
            Rect oldBounds  = mThumb.Bounds;
            int  halfThumb  = oldBounds.Width() / 2;
            int  addedThumb = mAddedTouchBounds;
            int  newX       = x - mDragOffset + halfThumb;
            int  left       = PaddingLeft + halfThumb + addedThumb;
            int  right      = Width - (PaddingRight + halfThumb + addedThumb);

            if (newX < left)
            {
                newX = left;
            }
            else if (newX > right)
            {
                newX = right;
            }

            int   available = right - left;
            float scale     = (float)(newX - left) / (float)available;

            if (IsRtl())
            {
                scale = 1f - scale;
            }
            int progress = (int)Math.Round((scale * (mMax - mMin)) + mMin);

            SetProgress(progress, true);
        }
Пример #9
0
 /// <summary>
 /// Rounds to decimal places.
 /// </summary>
 /// <seealso cref="RoundToDecimalPlaces">https://en.wikipedia.org/wiki/Significant_figures</seealso>
 /// <param name="value">The value.</param>
 /// <param name="decimalPlaces">The number of decimal places.</param>
 /// <param name="roundingTieBreaker">Method by which rounding is performed if the triggering rounding number is 5.</param>
 /// <returns>System.Double.</returns>
 public static double RoundToDecimalPlaces(
     double value,
     int decimalPlaces,
     RoundingTieBreaker roundingTieBreaker = RoundingTieBreaker.HalfAwayFromZero)
 {
     return(NMath.Round(value, decimalPlaces, midpointRounding(roundingTieBreaker)));
 }
        /// <summary>
        /// Requests the resource from all parts in the collection
        /// </summary>
        /// <param name="parts">All of the donor parts</param>
        /// <param name="transferGoal">the aggregate amount we are seeking to remove from parts</param>
        /// <returns>the amount we were successful at pulling</returns>
        private double PullResources(IList <global::Part> parts, double transferGoal, double deltaTime)
        {
            double toReturn           = 0.0;
            var    availableResources = CalculateAvailableResource(parts);

            foreach (var part in parts)
            {
                var resource = part.Resources.Get(resourceInfo.id);
                if (resource == null)
                {
                    continue;
                }

                var thisPartsPercentage = resource.amount / availableResources;

                // Throttle the transfer
                var thisPartsShare = transferGoal * thisPartsPercentage;
                var thisPartsRate  = resource.maxAmount * RESOURCE_SHARE_PER_UPDATE * deltaTime / 0.02;

                // The amount you pull must be negative
                thisPartsShare = -Math.Min(thisPartsShare, thisPartsRate);
                // the amount is subject to floating point lameness, if we round it here it is not material to the request but should make the numbers work out nicer.
                thisPartsShare = Math.Round(thisPartsShare, 5);

                toReturn += part.TransferResource(resourceInfo.id, thisPartsShare);
            }
            return(toReturn);
        }
Пример #11
0
        // Normalize coefficients à la Jenkins & Traub's RPOLY.
        // Normalization is done by scaling coefficients with a power of 2, so
        // that all the bits in the mantissa remain unchanged.
        // Use the infinity norm (max(sum(abs(a)…)) to determine the appropriate
        // scale factor. See @hkrish in #1087#issuecomment-231526156
        private static Real GetNormalizationFactor(params Real[] values)
        {
            var norm = values.Max();

            return(norm != 0 && (norm < 1e-8 || norm > 1e8)
                ? Math.Pow(2, -Math.Round(Math.Log(norm)))
                : 0f);
        }
Пример #12
0
        public static FrameSize CalculateImagePreviewSize(ImageParameters param, int maxWidth, int maxHeight = int.MaxValue)
        {
            var bounds = param.CropBounds;
            var w      = (int)Math.Max(Math.Round((bounds.Right - bounds.Left) / param.Scale), 0);
            var h      = (int)Math.Max(Math.Round((bounds.Bottom - bounds.Top) / param.Scale), 0);

            return(CalculateImagePreviewSize(w, h, maxWidth, maxHeight));
        }
Пример #13
0
        private void SetOrientation()
        {
            var metrics = new DisplayMetrics();

            Display.GetMetrics(metrics);

            var moduleWidth  = _cameraModule.Width * metrics.Density;
            var moduleHeight = _cameraModule.Height * metrics.Density;

            var    parameters = _camera.GetParameters();
            double proportionalPreviewHeight;

            switch (Display.Rotation)
            {
            case SurfaceOrientation.Rotation0:
                _cameraModule.IsViewInverted = false;
                _cameraModule.IsPortrait     = true;
                proportionalPreviewHeight    = _previewSize.Width * moduleWidth / _previewSize.Height;
                _camera.SetDisplayOrientation(90);
                parameters.SetRotation(90);
                break;

            case SurfaceOrientation.Rotation180:
                _cameraModule.IsViewInverted = true;
                _cameraModule.IsPortrait     = true;
                proportionalPreviewHeight    = _previewSize.Width * moduleWidth / _previewSize.Height;
                _camera.SetDisplayOrientation(270);
                parameters.SetRotation(270);
                break;

            case SurfaceOrientation.Rotation90:
                _cameraModule.IsViewInverted = false;
                _cameraModule.IsPortrait     = false;
                proportionalPreviewHeight    = _previewSize.Height * moduleWidth / _previewSize.Width;
                _camera.SetDisplayOrientation(0);
                parameters.SetRotation(0);
                break;

            default:
                _cameraModule.IsPortrait     = false;
                _cameraModule.IsViewInverted = true;
                proportionalPreviewHeight    = _previewSize.Height * moduleWidth / _previewSize.Width;
                _camera.SetDisplayOrientation(180);
                parameters.SetRotation(180);
                break;
            }
            _camera.SetParameters(parameters);

            var verticalOffset = (moduleHeight - proportionalPreviewHeight) / 2f;

            _textureView.SetX(0);
            _textureView.SetY((float)verticalOffset);

            _cameraModule.PreviewBottomY = _cameraModule.Height - verticalOffset / 2;

            _textureView.LayoutParameters = new FrameLayout.LayoutParams((int)Math.Round(moduleWidth),
                                                                         (int)Math.Round(proportionalPreviewHeight));
        }
Пример #14
0
            private void WheelSteer(FlightCtrlState c)
            {
                if (!Enabled)
                {
                    return;
                }
                float bearing = 0;

                if (value is VesselTarget)
                {
                    bearing = VesselUtils.GetTargetBearing(control.Vessel, ((VesselTarget)value).Vessel);
                }
                else if (value is GeoCoordinates)
                {
                    bearing = (float)((GeoCoordinates)value).GetBearing();
                }
                else
                {
                    try
                    {
                        double doubleValue = Convert.ToDouble(value);
                        if (Utils.IsValidNumber(doubleValue))
                        {
                            bearing = (float)(Math.Round(doubleValue) - Mathf.Round(FlightGlobals.ship_heading));
                            if (bearing < -180)
                            {
                                bearing += 360; // i.e. 359 degrees to the left is really 1 degree to the right.
                            }
                            else if (bearing > 180)
                            {
                                bearing -= 360; // i.e. 359 degrees to the right is really 1 degree to the left
                            }
                        }
                    }
                    catch (InvalidCastException) // Note, very few types actually fail Convert.ToDouble(), so it's hard to get this to occur.
                    {
                        // perform the "unlock" so this message won't spew every FixedUpdate:
                        Enabled = false;
                        ClearValue();
                        throw new KOSWrongControlValueTypeException(
                                  "WHEELSTEER", value.GetType().Name, "Vessel, LATLNG, or Number (compass heading)");
                    }
                }

                if (!(control.Vessel.horizontalSrfSpeed > 0.1f))
                {
                    return;
                }

                if (Mathf.Abs(VesselUtils.AngleDelta(VesselUtils.GetHeading(control.Vessel), VesselUtils.GetVelocityHeading(control.Vessel))) <= 90)
                {
                    c.wheelSteer = Mathf.Clamp(bearing / -10, -1, 1);
                }
                else
                {
                    c.wheelSteer = -Mathf.Clamp(bearing / -10, -1, 1);
                }
            }
Пример #15
0
        public void ExecuteCommandPos(IRocketPlayer caller, string[] _)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;
            string         x      = Math.Round(player.Position.x).ToString();
            string         y      = Math.Round(player.Position.y).ToString();
            string         z      = Math.Round(player.Position.z).ToString();

            UnturnedChat.Say(player, Translate("pos", x, y, z), Color.cyan);
        }
        /// <summary>
        /// Reduces the array size if necessary.
        /// </summary>
        protected void reduceArraySizeIfNecessary()
        {
            int newLength = NMath.Max((int)NMath.Round(_contents.Length / (double)_arrayResizeRatio), _minArraySize);

            if (Count < newLength)
            {
                resizeArray(newLength);
            }
        }
        public async void GetStoreDetails(ProductListModel productListModel)
        {
            var request         = new GeolocationRequest(GeolocationAccuracy.Medium);
            var Currentlocation = await Geolocation.GetLocationAsync(request);

            //StoreList = new List<StoreDetailModel>();


            //var Url = "http://shopbasket.azurewebsites.net/api/Search";
            var Url = "http://10.0.2.2:5000/api/Search";

            HttpClient httpClient = new HttpClient();



            //var user = new User();

            //var jsonObject = JsonConvert.SerializeObject(productListModel);
            //var content = new StringContent(jsonObject, Encoding.UTF8, "application/json");

            var response = await httpClient.GetAsync(Url + "/" + productListModel.Barcode);

            if (response.IsSuccessStatusCode)
            {
                var content2 = await response.Content.ReadAsStringAsync();

                if (content2 == "")
                {
                }
                else
                {
                    var StoreInfo = JsonConvert.DeserializeObject <List <StoreDetailModel> >(content2);
                    StoreList = new ObservableCollection <StoreDetailModel>(StoreInfo);

                    foreach (var Store in StoreList)
                    {
                        var storeLocation = new Location(double.Parse(Store.Latitude), double.Parse(Store.longitude));
                        var testLocation  = new Location(-33.96842050869081, 25.62738453084694); // test****

                        double distance = Math.Round(testLocation.CalculateDistance(storeLocation, DistanceUnits.Kilometers), 2);

                        Store.Distance = distance.ToString() + " Km";
                    }
                }



                //var user = new User();
                //user = jsonObject.
            }
            else
            {
                Debug.WriteLine("An error occured while loading data");
            }
        }
Пример #18
0
        partial void UpdateFontPartial()
        {
            if (Parent != null && _textBoxView != null)
            {
                var style    = TypefaceStyleHelper.GetTypefaceStyle(FontStyle, FontWeight);
                var typeface = FontHelper.FontFamilyToTypeFace(FontFamily, FontWeight);

                _textBoxView.SetTypeface(typeface, style);
                _textBoxView.SetTextSize(ComplexUnitType.Px, (float)Math.Round(ViewHelper.LogicalToPhysicalFontPixels((float)FontSize)));
            }
        }
Пример #19
0
        public static void SetPathEWRNP()
        {
            lock (thisLock)
            {
                path_ewrnp = (byte)(path_ewrnp_Parent + Math.Round(CalculateLinkEWRNP_Parent()));

                // Reset counts for next Window
                numReceivedInCurrentWindow_Parent = 0;
                numTriesInCurrentWindow_Parent    = 0;
            }
        }
Пример #20
0
        private void UpdateKeyboardRange()
        {
            int range = mMax - mMin;

            if ((mKeyProgressIncrement == 0) || (range / mKeyProgressIncrement > 20))
            {
                // It will take the user too long to change this via keys, change it
                // to something more reasonable
                mKeyProgressIncrement = (int)Math.Max(1, Math.Round((float)range / 20));
            }
        }
Пример #21
0
        public void SetPathEWRNP()
        {
            lock (thisLock)
            {
                path_ewrnp = (byte)(path_ewrnp_Base_to_Candidate + Math.Round(CalculateLinkEWRNP()));

                // Reset counts for next Window
                this.numReceivedInCurrentWindow = 0;
                this.numTriesInCurrentWindow    = 0;
            }
        }
Пример #22
0
        public byte GetVoxel(Vector3 pos)
        {
            if (!inGrid(pos))
            {
                return(AIR_VOXEL);
            }

            int x = (int)Math.Round(pos.X);
            int y = (int)Math.Round(pos.Y);
            int z = (int)Math.Round(pos.Z);

            return(Voxels[y * ZScale + x * ZScale * XScale + z]);
        }
Пример #23
0
        /// <summary>
        /// Creates an evaluation pointlist.
        /// </summary>
        /// <param name="points">Points to evaluate</param>
        /// <param name="direction">direction to evaluate (normaly z-direction)</param>
        /// <returns>pointList</returns>
        public static string EvaluationPointsList(List <Point> points, Vector direction)
        {
            var n         = points.Count - 1;
            var pointList = "";

            for (var i = 0; i < n; i++)
            {
                pointList += Math.Round(points[i].X, 2) + " " + Math.Round(points[i].Y, 2) + " " + Math.Round(points[i].Z, 2) + " " + Math.Round(direction.X) + " " + Math.Round(direction.Y) + " " + Math.Round(direction.Z) + "\n";
            }
            pointList += Math.Round(points[n].X, 2) + " " + Math.Round(points[n].Y, 2) + " " + Math.Round(points[n].Z, 2) + " " + Math.Round(direction.X) + " " + Math.Round(direction.Y) + " " + Math.Round(direction.Z);

            return(pointList);
        }
Пример #24
0
        public void SetVoxel(Vector3 pos, byte v)
        {
            if (!inGrid(pos))
            {
                return;
            }

            int x = (int)Math.Round(pos.X);
            int y = (int)Math.Round(pos.Y);
            int z = (int)Math.Round(pos.Z);

            Voxels[y * ZScale + x * ZScale * XScale + z] = v;
        }
Пример #25
0
    public override void Attack(Transform spawnPosition, Vector3 targetPosition, string enemyTag, float attack)
    {
        Projectile projectileInstance = Instantiate(Projectile, spawnPosition.position, Quaternion.identity);

        projectileInstance.EnemyTag = enemyTag;
        projectileInstance.Attack   = (float)Math.Round(attack / 0.8f, 2);
        HelperUtilities.LookAt2D(projectileInstance.transform, targetPosition, -90);
        projectileInstance.Rigidbody2D.AddForce(projectileInstance.transform.up * ShootForce);

        HelperUtilities.LookAt2D(projectileInstance.transform, targetPosition, 0);
        projectileInstance.DestroyOnCollision = false;
        Destroy(projectileInstance.gameObject, TimeToDestroy);
    }
        public void SetOutputModulationFrequency(double frequencyHz = Pca9685.DefaultOutputModulationFrequency)
        {
            // See PCA9685 data sheet, pp.24 for details on calculating the prescale value.
            var computedPrescale = Math.Round(Pca9685.InternalOscillatorFrequencyHz / 4096.0 / frequencyHz) - 1;

            if (computedPrescale < 3.0 || computedPrescale > 255.0)
            {
                throw new ArgumentOutOfRangeException("frequencyHz", "range 24 Hz to 1743 Hz");
            }
            var prescale = (byte)computedPrescale;

            SetPrescale(prescale);
            outputModulationFrequencyHz = frequencyHz;
        }
Пример #27
0
 public void FillVoxels(Vector3 min, Vector3 max, byte v)
 {
     for (int x = (int)Math.Round(min.X); x < (int)Math.Round(max.X); x++)
     {
         for (int y = (int)Math.Round(min.Y); y < (int)Math.Round(max.Y); y++)
         {
             for (int z = (int)Math.Round(min.Z); z < (int)Math.Round(max.Z); z++)
             {
                 ///Console.WriteLine("({0},{1},{2}) {3}",x,y,z,v);
                 SetVoxel(x, y, z, v);
             }
         }
     }
 }
Пример #28
0
        private ImageCache(int maxCacheSize, IMiniLogger logger, bool verboseLogging)
        {
            _logger = logger;
            int safeMaxCacheSize = GetMaxCacheSize(maxCacheSize);

            double sizeInMB = Math.Round(safeMaxCacheSize / 1024d / 1024d, 2);

            logger.Debug(string.Format("Image memory cache size: {0} MB", sizeInMB));

            // consider low treshold as a third of maxCacheSize
            int lowTreshold = safeMaxCacheSize / 3;

            _cache             = new ReuseBitmapDrawableCache(logger, safeMaxCacheSize, lowTreshold, safeMaxCacheSize, verboseLogging);
            _imageInformations = new ConcurrentDictionary <string, ImageInformation>();
        }
Пример #29
0
        public override Position EstimateNextPosition()
        {
            var acc    = this.Acc / this.Mass;
            var nextVx = (int)Math.Round((this.Speed.Vx + acc) * (1 - this.Friction));
            var nextVy = (int)Math.Round((this.Speed.Vy + acc) * (1 - this.Friction));

            var x = this.Pos.X + nextVx;
            var y = this.Pos.Y + nextVy;

            return(new Position
            {
                X = x,
                Y = y
            });
        }
Пример #30
0
        public static FrameSize CalculateImagePreviewSize(int width, int height, int maxWidth, int maxHeight)
        {
            var nh = (int)Math.Round(maxWidth * height / (float)width);

            if (maxHeight == int.MaxValue)
            {
                return(new FrameSize(nh, maxWidth));
            }

            var nw = (int)Math.Round(maxHeight * width / (float)height);

            return(nh > maxHeight
                ? new FrameSize(maxHeight, nw)
                : new FrameSize(nh, maxWidth));
        }