Пример #1
0
        int IComparable.CompareTo(object obj)
        {
            ThreeDPolygon ptest = (ThreeDPolygon)obj; // unbox
            float         sum1  = GetZSum(this);
            float         sum2  = GetZSum(ptest);

            if (sum1 > sum2)
            {
                return(1);
            }

            if (sum1 == sum2)
            {
                sum1 = GetXSum(this);
                sum2 = GetXSum(ptest);
                if (sum1 > sum2)
                {
                    return(1);
                }
            }

            if (sum1 == sum2)
            {
                sum1 = GetYSum(this);
                sum2 = GetYSum(ptest);
                if (sum1 > sum2)
                {
                    return(1);
                }
            }


            return(-1);
        }
Пример #2
0
        object ICloneable.Clone()
        {
            ThreeDPolygon copyObject = new ThreeDPolygon();

            for (int i = 0; i < Vertices.Count; i++)
            {
                copyObject.Vertices.Add(((ICloneable)Vertices[i]).Clone());
            }

            return(copyObject);
        }
Пример #3
0
        float GetYSum(ThreeDPolygon p)
        {
            float sum = 0.0f;

            for (int i = 0; i < Vertices.Count; i++)
            {
                sum += ((ThreeDPoint)p.Vertices[i]).Y;
            }

            return(sum);
        }
Пример #4
0
 public void AddPolygon(ThreeDPolygon aPolygon)
 {
     Polygons.Add(aPolygon);
 }