public void HorizonAlgrorithm(Spacing ParX, Spacing ParZ, Graphics Painter, double Tetax, double Tetay, double Tetaz) { PrepareArray(); int LeftX = -1, LeftY = -1, RightX = -1, RightY = -1; int PrevX = 0, PrevY = 0; for (double z = ParZ.End; z >= ParZ.Start; z -= ParZ.Delta) { double Yp = f(ParX.Start, z); Transform(ref ParX.Start, ref Yp, ref z, Tetax, Tetay, Tetaz, ref PrevX, ref PrevY); EdgeProcessing(ref PrevX, ref PrevY, ref LeftX, ref LeftY, Painter); int Pflag = Visible(PrevX, PrevY); for (double x = ParX.Start; x <= ParX.End; x += ParX.Delta) { int CurrX = 0, CurrY = 0; int xi = 0, yi = 0; Yp = f(x, z); Transform(ref x, ref Yp, ref z, Tetax, Tetay, Tetaz, ref CurrX, ref CurrY); int Tflag = Visible(CurrX, CurrY); if (Tflag == Pflag) { if (Pflag != 0) { horizon(PrevX, PrevY, CurrX, CurrY, Painter); } } else if (Tflag == 0) { if (Pflag == 1) { GetIntersection(PrevX, PrevY, CurrX, CurrY, Top, ref xi, ref yi); } else { GetIntersection(PrevX, PrevY, CurrX, CurrY, Down, ref xi, ref yi); } horizon(PrevX, PrevY, xi, yi, Painter); } else if (Tflag == 1) { if (Pflag == 0) { GetIntersection(PrevX, PrevY, CurrX, CurrY, Top, ref xi, ref yi); horizon(PrevX, PrevY, xi, yi, Painter); } else { GetIntersection(PrevX, PrevY, CurrX, CurrY, Top, ref xi, ref yi); horizon(PrevX, PrevY, xi, yi, Painter); GetIntersection(PrevX, PrevY, CurrX, CurrY, Down, ref xi, ref yi); horizon(xi, yi, CurrX, CurrY, Painter); } } else { if (Pflag == 0) { GetIntersection(PrevX, PrevY, CurrX, CurrY, Down, ref xi, ref yi); horizon(PrevX, PrevY, xi, yi, Painter); } else { GetIntersection(PrevX, PrevY, CurrX, CurrY, Top, ref xi, ref yi); horizon(PrevX, PrevY, xi, yi, Painter); GetIntersection(PrevX, PrevY, CurrX, CurrY, Down, ref xi, ref yi); horizon(xi, yi, CurrX, CurrY, Painter); } } Pflag = Tflag; PrevX = CurrX; PrevY = CurrY; } EdgeProcessing(ref PrevX, ref PrevY, ref RightX, ref RightY, Painter); } }