Exemplo n.º 1
0
        public int CompareTo(object obj)
        {
            SP2 sp2 = obj as SP2;

            if (this.pos.x == sp2.pos.x && this.pos.y == sp2.pos.y)
            {
                return(0);
            }

            return(this.val.CompareTo(sp2.val));
        }
Exemplo n.º 2
0
        private ResultCheckSlope CheckSlope(SP2 p)//, List<SP2> listSP2
        {
            ResultCheckSlope res = new ResultCheckSlope();

            float slopesum = 0f;
            float zp       = p.val;

            for (int i = -1; i < 1; i++)
            {
                for (int j = -1; j < 1; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        continue;
                    }
                    if (p.pos.x + i <= 0 || p.pos.x + i >= nx - 1 || p.pos.y + j <= 0 || p.pos.y + j >= ny - 1)
                    {
                        continue;
                    }
                    float step = this.at(p.pos.x + i, p.pos.y + j) - zp;
                    if (step < 0f)
                    {
                        if ((i + j) % 2 != 0)
                        {
                            res.slope[res.nb] = -step;
                        }
                        else
                        {
                            res.slope[res.nb] = -step / Mathf.Sqrt(2);
                        }

                        slopesum     += res.slope[res.nb];
                        res.q[res.nb] = new SP2(this.at(p.pos.x + i, p.pos.y + j), new Vector2Int(p.pos.x + i, p.pos.y + j));
                        res.nb++;
                    }
                }
            }

            for (int i = 0; i < res.nb; i++)
            {
                res.avSlope[i] = res.slope[i] / slopesum;
            }

            return(res);
        }