Exemple #1
0
        /// <summary>
        /// Calculates a dot product of the contour
        /// </summary>
        public unsafe Complex Dot(Contour c, int shift)
        {
            var    count = Count;
            double sumA  = 0;
            double sumB  = 0;

            // fixed pointers -> .NET can't change the object it points to
            fixed(Complex *ptr1 = &array[0])
            fixed(Complex * ptr2  = &c.array[shift])
            fixed(Complex * ptr22 = &c.array[0])
            fixed(Complex * ptr3  = &c.array[c.Count - 1])
            {
                Complex *p1 = ptr1;
                Complex *p2 = ptr2;

                // for all vertices, multiply them with a SHIFT value
                for (int i = 0; i < count; i++)
                {
                    Complex x1 = *p1;
                    Complex x2 = *p2;
                    sumA += x1.a * x2.a + x1.b * x2.b;
                    sumB += x1.b * x2.a - x1.a * x2.b;

                    p1++;
                    if (p2 == ptr3)
                    {
                        p2 = ptr22;
                    }
                    else
                    {
                        p2++;
                    }
                }
            }
            return(new Complex(sumA, sumB));
        }
Exemple #2
0
 /// <summary>
 /// Calculates dot product with given contour
 /// </summary>
 /// <returns></returns>
 public Complex Dot(Contour c)
 {
     return(Dot(c, 0));
 }