Пример #1
0
 public static ImaginaryNumber operator +(ImaginaryNumber imaginaryNum1, ImaginaryNumber imaginaryNum2)
 {
     ImaginaryNumber newImaginaryNum = new ImaginaryNumber();
     newImaginaryNum.RealComponent = imaginaryNum1.RealComponent + imaginaryNum2.RealComponent;
     newImaginaryNum.ImaginaryComponent = imaginaryNum1.ImaginaryComponent + imaginaryNum2.ImaginaryComponent;
     return newImaginaryNum;
 }
Пример #2
0
 public bool IsMandelbrotSetMember(double x, double y, out int TestedIterations)
 {
     int i;
     bool result = true;
     ImaginaryNumber C = new ImaginaryNumber(x, y);
     ImaginaryNumber Z = new ImaginaryNumber(0, 0);
     double distanceFromBase = 0;
     for (i = 0; i < IterationsLimit && result; i++)
     {
         Z = GetNextZ(Z, C);
         distanceFromBase = CalcDistFromBase(Z);
         if (distanceFromBase > 2)
             result = false;
     }
     TestedIterations = i;
     return result;
 }
Пример #3
0
 private ImaginaryNumber GetNextZ(ImaginaryNumber Z, ImaginaryNumber C)
 {
     ImaginaryNumber resultNumber = Z.PowerOfTwo() + C;
     return resultNumber;
 }
Пример #4
0
 private double CalcDistFromBase(ImaginaryNumber Z)
 {
     return Math.Sqrt(Math.Pow(Z.RealComponent, 2) + Math.Pow(Z.ImaginaryComponent, 2));
 }