Esempio n. 1
0
        /// <summary>
        /// Shifts the positions of the coordinates until the coordinate at  <code>firstCoordinateIndex</code>
        /// is first.
        /// </summary>
        /// <param name="seq">The coordinate sequence to rearrange</param>
        /// <param name="indexOfFirstCoordinate">The index of the coordinate to make first</param>
        /// <param name="ensureRing">Makes sure that <paramref name="seq"/> will be a closed ring upon exit</param>
        public static void Scroll(CoordinateSequence seq, int indexOfFirstCoordinate, bool ensureRing)
        {
            int i = indexOfFirstCoordinate;

            if (i <= 0)
            {
                return;
            }

            // make a copy of the sequence
            var copy = seq.Copy();

            // test if ring, determine last index
            int last = ensureRing ? seq.Count - 1 : seq.Count;

            // fill in values
            for (int j = 0; j < last; j++)
            {
                for (int k = 0; k < seq.Dimension; k++)
                {
                    seq.SetOrdinate(j, k, copy.GetOrdinate((indexOfFirstCoordinate + j) % last, k));
                }
            }

            // Fix the ring (first == last)
            if (ensureRing)
            {
                for (int k = 0; k < seq.Dimension; k++)
                {
                    seq.SetOrdinate(last, k, seq.GetOrdinate(0, k));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Swaps two coordinates in a sequence.
        /// </summary>
        /// <param name="seq">seq the sequence to modify</param>
        /// <param name="i">the index of a coordinate to swap</param>
        /// <param name="j">the index of a coordinate to swap</param>
        public static void Swap(CoordinateSequence seq, int i, int j)
        {
            if (i == j)
            {
                return;
            }

            for (int dim = 0; dim < seq.Dimension; dim++)
            {
                double tmp = seq.GetOrdinate(i, dim);
                seq.SetOrdinate(i, dim, seq.GetOrdinate(j, dim));
                seq.SetOrdinate(j, dim, tmp);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Copies a coordinate of a <see cref="CoordinateSequence"/> to another <see cref="CoordinateSequence"/>.
        /// The sequences may have different dimensions;
        /// in this case only the common dimensions are copied.
        /// </summary>
        /// <param name="src">The sequence to copy coordinate from</param>
        /// <param name="srcPos">The index of the coordinate to copy</param>
        /// <param name="dest">The sequence to which the coordinate should be copied to</param>
        /// <param name="destPos">The index of the coordinate in <see paramref="dest"/></param>
        public static void CopyCoord(CoordinateSequence src, int srcPos, CoordinateSequence dest, int destPos)
        {
            int minDim = Math.Min(src.Dimension, dest.Dimension);

            for (int dim = 0; dim < minDim; dim++)
            {
                double value = src.GetOrdinate(srcPos, dim);
                dest.SetOrdinate(destPos, dim, value);
            }
        }
Esempio n. 4
0
 public override void SetOrdinate(int index, int ordinateIndex, double value) => _inner.SetOrdinate(Count - index - 1, ordinateIndex, value);