Example #1
0
 public void CopyFrom(ApCoeffs coeffs)
 {
     for (int i = 0; i < Length; i++)
     {
         _coefficients[i].CopyFrom(coeffs._coefficients[i]);
     }
 }
Example #2
0
 public ApCoeffs(ApCoeffs source)
 {
     _coefficients = new DPoint[source.Length];
     for (int i = 0; i < source.Length; i++)
     {
         _coefficients[i] = new DPoint(source[i]);
     }
 }
Example #3
0
        public void ComputeNextE2(ApCoeffs coeffs)
        {
            E2 = coeffs[0] * D;           // A * D

            DPoint t = D * D;             // D^2

            E2 += coeffs[1] * t;          //B * D^2;

            E2 += coeffs[2] * t * D;      // C * D^3;
        }
Example #4
0
 private ApCoeffs CopyOrSet(ApCoeffs source, ApCoeffs dest)
 {
     if (dest == null)
     {
         ApCoeffs temp = new ApCoeffs(source);
         return(temp);
     }
     else
     {
         dest.CopyFrom(source);
         return(dest);
     }
 }
Example #5
0
        public ApCell(DPoint c, ApDetail[] details)
        {
            RefC    = c;
            Details = details;

            RefZ = new DPoint(0, 0);
            xSq  = 0;
            ySq  = 0;

            _coeffs = new ApCoeffs(3);

            _coeffHistory = new RingBuf <ApCoeffs>(10, CopyOrSet);
            _zHistory     = new RingBuf <DPoint>(10, CopyOrSet2);
        }
Example #6
0
        private void UpdateCoefficients(DPoint z, ApCoeffs coeffs)
        {
            DPoint twoZ = new DPoint(z).Scale(2);     // z * 2;

            DPoint ta = twoZ * coeffs[0];             // 2z * a + 1;

            ta.X += 1;

            DPoint tb = twoZ * coeffs[1] + coeffs[0] * coeffs[0];                      // 2z * b + a^2

            DPoint tc = twoZ * coeffs[2] + new DPoint(coeffs[0]).Scale(2) * coeffs[1]; // twoZ * C + 2ab

            coeffs[0].CopyFrom(ta);
            coeffs[1].CopyFrom(tb);
            coeffs[2].CopyFrom(tc);
        }
Example #7
0
        public int[] Iterate3(int targetIterations)
        {
            int[] result = new int[9];

            int centerCnt = IterateCentral(targetIterations);

            RefZ    = _zHistory.Read(_zHistory.Count - 1);
            xSq     = RefZ.X * RefZ.X;
            ySq     = RefZ.Y * RefZ.Y;
            _coeffs = _coeffHistory.Read(_coeffHistory.Count - 1);

            int cnt = centerCnt - (_coeffHistory.Count - 1);

            for (int i = 0; i < 8; i++)
            {
                Details[i].Cnt2 = cnt;
            }

            bool isEscaped = false;

            while (!isEscaped && cnt < targetIterations)
            {
                // Compute next E for each neighbor using current value of Z
                UpdateCoefficients(RefZ, _coeffs);

                for (int i = 0; i < 8; i++)
                {
                    if (!Details[i].HasEscaped2)
                    {
                        Details[i].ComputeNextE2(_coeffs);
                    }
                }

                RefZ.Y = 2 * RefZ.X * RefZ.Y + RefC.Y;
                RefZ.X = xSq - ySq + RefC.X;

                xSq = RefZ.X * RefZ.X;
                ySq = RefZ.Y * RefZ.Y;

                isEscaped = true;
                for (int i = 0; i < 8; i++)
                {
                    if (!Details[i].HasEscaped2)
                    {
                        isEscaped &= Details[i].ComputeNextZ2(RefZ);
                    }
                }

                cnt++;
            }

            result[0] = Details[0].Cnt2 * CNT_MULTIPLIER;
            result[1] = Details[1].Cnt2 * CNT_MULTIPLIER;;
            result[2] = Details[2].Cnt2 * CNT_MULTIPLIER;;

            result[3] = Details[3].Cnt2 * CNT_MULTIPLIER;;
            result[4] = centerCnt * CNT_MULTIPLIER;
            result[5] = Details[4].Cnt2 * CNT_MULTIPLIER;;

            result[6] = Details[5].Cnt2 * CNT_MULTIPLIER;;
            result[7] = Details[6].Cnt2 * CNT_MULTIPLIER;;
            result[8] = Details[7].Cnt2 * CNT_MULTIPLIER;;

            return(result);
        }