Exemplo n.º 1
0
        public static double FindNextSquare(double attemptVal, Skew s)
        {
            double newVal  = attemptVal;
            Skew   newSkew = Skew.None;
            double square  = 0;

            if (!IsSquare(newVal, out square))
            {
                double decimalValue = GetDecimalValue(square);
                newSkew = GetSkewFromDecimal(decimalValue);

                if (newSkew == Skew.Greater)
                {
                    newVal--;
                }
                else
                {
                    newVal++;
                }

                newVal = FindNextSquare(newVal, newSkew);
            }

            return(newVal);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts <see cref="AnalogChannel"/> to its string format.
        /// </summary>
        public override string ToString()
        {
            // An,ch_id,ph,ccbm,uu,a,b,skew,min,max
            List <string> values = new List <string>
            {
                Index.ToString(),
                          Name,
                          PhaseID,
                          CircuitComponent,
                          Units,
                          Multiplier.ToString(CultureInfo.InvariantCulture),
                Adder.ToString(CultureInfo.InvariantCulture),
                Skew.ToString(CultureInfo.InvariantCulture),
                MinValue.ToString(CultureInfo.InvariantCulture),
                MaxValue.ToString(CultureInfo.InvariantCulture)
            };

            // ...,primary,secondary,PS
            if (m_version >= 1999)
            {
                values.Add(PrimaryRatio.ToString(CultureInfo.InvariantCulture));
                values.Add(SecondaryRatio.ToString(CultureInfo.InvariantCulture));
                values.Add(ScalingIdentifier.ToString());
            }

            return(string.Join(",", values));
        }
Exemplo n.º 3
0
        public static int FindNextSquare(int i)
        {
            Skew s      = Skew.None;
            var  result = FindNextSquare(i, s);

            return((int)Math.Sqrt(result));
        }
Exemplo n.º 4
0
 public void Merge(Skew Group)
 {
     this.rx   = this.rx + Group.rx;
     this.rx2  = this.rx2 + Group.rx2;
     this.r2x  = this.r2x + Group.r2x;
     this.rx3  = this.rx3 + Group.rx3;
     this.r3x2 = this.r3x2 + Group.r3x2;
     this.r3x  = this.r3x + Group.r3x;
     this.rn   = this.rn + Group.rn;
 }
Exemplo n.º 5
0
 // constructor
 protected DisplayObject() : base()
 {
     TextureBounds = new RectD();
     Color         = new Color(255, 255, 255, 255);
     Skew          = new Skew();
     //Skew.Changed += OnSkewChanged;
     Scale                    = new PointD(1.0d, 1.0d);
     Scale.Changed           += OnScaleChanged;
     TransformOffset          = new PointD();
     TransformOffset.Changed += OnTransformChanged;
     Graphics                 = new Graphics();
     Graphics.Changed        += OnGraphicsChanged;
 }
Exemplo n.º 6
0
        //------------------------------------------------------------------------------------------

        private static List <Skew> PathDirections()
        {
            var topR = new Skew(m_topRight);
            var botR = new Skew(m_bottomRight);
            var botL = new Skew(m_bottomLeft);
            var topL = new Skew(m_topLeft);

            return(new List <Skew>
            {
                new Straight(m_up, topR, topL),
                new Straight(m_right, topR, botR),
                new Straight(m_down, botR, botL),
                new Straight(m_left, botL, topL),
                topR,
                botR,
                botL,
                topL
            });
        }
Exemplo n.º 7
0
        /// <summary>Constructs an instance of the <see cref="GeneralizedSuffixArray"/> class.</summary>
        /// <param name="textWithPadding">The text. The character of this texts are integers. Each unique element of the original text (or list of objects) is mapped to an unique integer value, while preserving the lexicographical order of the original characters in the integer values.</param>
        /// <param name="textLength">Number of characters of the text. This usually is smaller than the length of text array.</param>
        /// <param name="numberOfWords">The number of words in the original text, if the original text was separated into words. Otherwise, this parameter should be 1.</param>
        /// <param name="wordStartPositions">The start positions of the words in the text array, if the original text was separated into words. Otherwise, this parameter is ignored.</param>
        /// <param name="alphabetSize">Size of the alphabet. This is the number of unique characters (or objects) of the original text. If the text was separated into words, the numberOfWords is added, since each separator is a unique character.</param>
        protected GeneralizedSuffixArray(int[] textWithPadding, int textLength, int numberOfWords, int[] wordStartPositions, int alphabetSize)
        {
            if (null == textWithPadding)
            {
                throw new ArgumentNullException("stringWithPadding is null");
            }
            if (textWithPadding.Length < (textLength + RequiredTextPadding))
            {
                throw new ArgumentNullException("array textWithPadding has to be at least 3 elements longer than the number of data (stringLength)");
            }
            if (numberOfWords > 1)
            {
                if (null == wordStartPositions)
                {
                    throw new ArgumentNullException("wordBegins is null");
                }
                if (wordStartPositions.Length < numberOfWords + 1)
                {
                    throw new ArgumentException("wordBegins must have at least (numberOfWords+1) elements");
                }
                if (wordStartPositions[numberOfWords] != textLength)
                {
                    throw new ArgumentException("end element of array wordBegins is unequal to stringLength. Did you make a mistake in calculating the wordBegins (for instance, forgot taking separators into account)?");
                }
            }

            _text               = textWithPadding;
            _textLength         = textLength;
            _numberOfWords      = numberOfWords;
            _alphabetSize       = alphabetSize;
            _wordStartPositions = wordStartPositions;

            _suffixArray        = Skew.GetSuffixArray(_text, _textLength, _alphabetSize, new int[_textLength]);
            _inverseSuffixArray = CalculateInverseSuffixArray(_suffixArray);
            _LCP = CalculateLcpArray(_suffixArray, _inverseSuffixArray, _text, _textLength);

            if (numberOfWords >= 2)
            {
                _wordIndices = CalculateWordIndices(_suffixArray, _inverseSuffixArray, _wordStartPositions, _numberOfWords);
                _LCPS        = calc_lcptabs(_suffixArray, _inverseSuffixArray, _text, _suffixArray.Length, _numberOfWords, _wordIndices);
            }
        }
        internal string ToCFGString()
        {
            var cfgValues = new[] {
                Index.ToString(),
                Name,
                Phase,
                CircuitComponent,
                Units,
                MultiplierA.ToString(CultureInfo.InvariantCulture),
                MultiplierB.ToString(CultureInfo.InvariantCulture),
                Skew.ToString(CultureInfo.InvariantCulture),
                Min.ToString(CultureInfo.InvariantCulture),
                Max.ToString(CultureInfo.InvariantCulture),
                Primary.ToString(CultureInfo.InvariantCulture),
                Secondary.ToString(CultureInfo.InvariantCulture),
                IsPrimary ? "P" : "S"
            };

            return(string.Join(GlobalSettings.Comma.ToString(), cfgValues));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Converts <see cref="AnalogChannel"/> to its string format.
        /// </summary>
        public override string ToString()
        {
            string[] values = new string[13];

            // An,ch_id,ph,ccbm,uu,a,b,skew,min,max,primary,secondary,PS
            values[0]  = Index.ToString();
            values[1]  = Name;
            values[2]  = PhaseID;
            values[3]  = CircuitComponent;
            values[4]  = Units;
            values[5]  = Multiplier.ToString(CultureInfo.InvariantCulture);
            values[6]  = Adder.ToString(CultureInfo.InvariantCulture);
            values[7]  = Skew.ToString(CultureInfo.InvariantCulture);
            values[8]  = MinValue.ToString();
            values[9]  = MaxValue.ToString();
            values[10] = PrimaryRatio.ToString(CultureInfo.InvariantCulture);
            values[11] = SecondaryRatio.ToString(CultureInfo.InvariantCulture);
            values[12] = ScalingIdentifier.ToString();

            return(values.ToDelimitedString(','));
        }
Exemplo n.º 10
0
 public Straight(Vector2 a_direction, Skew a_cOne, Skew a_cTwo)
     : base(a_direction)
 {
     m_cOne = a_cOne;
     m_cTwo = a_cTwo;
 }
Exemplo n.º 11
0
        //------------------------------------------------------------------------------------------

        public List <KD2DTile> FindPath(KDNav2DAgent a_agent)
        {
            GameObject endTile = NearestTile(a_agent.Destination).gameObject;

            RestartMail(a_agent.NearestTile.gameObject, m_openList, m_closedList);

            if (endTile != a_agent.NearestTile.gameObject)
            {
                GameObject tileGo;
                Vector2    end = endTile.transform.position;
                do
                {
                    KD2DTile currentTile;
                    BinaryDelete(m_openList, m_closedList, out tileGo, out currentTile);

                    int         i          = 0;
                    List <Skew> dirs       = PathDirections();
                    Collider2D  collider2D = tileGo.collider2D;
                    collider2D.enabled = false;
                    do
                    {
                        Skew         dir = dirs[i];
                        RaycastHit2D hit = Physics2D.Raycast
                                           (
                            tileGo.transform.position,
                            dir.Direction.normalized,
                            dir.Direction.magnitude,
                            1 << m_tileLayer
                                           );

                        if (hit)
                        {
                            var hitTile = hit.collider.GetComponent <KD2DTile>();
                            if (hitTile && !hitTile.Occupied && !hitTile.IsBloked)
                            {
                                float nextG = currentTile.G + dir.Cost;
                                if (!hitTile.IsWrited)
                                {
                                    WriteTile(hitTile, tileGo, nextG, end);
                                    continue;
                                }

                                if (hitTile.G > nextG)
                                {
                                    WriteTile(hitTile, tileGo, nextG);
                                }
                            }
                            else
                            {
                                dir.RemoveFromList(dirs);
                            }
                        }
                        else
                        {
                            dir.RemoveFromList(dirs);
                        }
                    } while (++i < dirs.Count);
                    collider2D.enabled = true;
                } while (tileGo != endTile && m_openList.Count > 0);
            }

            var finalList = new List <KD2DTile>();

            if (endTile)
            {
                finalList = FinalList(endTile.GetComponent <KD2DTile>());
            }

            return(finalList);
        }