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); }
object ICloneable.Clone() { ThreeDPolygon copyObject = new ThreeDPolygon(); for (int i = 0; i < Vertices.Count; i++) { copyObject.Vertices.Add(((ICloneable)Vertices[i]).Clone()); } return(copyObject); }
float GetYSum(ThreeDPolygon p) { float sum = 0.0f; for (int i = 0; i < Vertices.Count; i++) { sum += ((ThreeDPoint)p.Vertices[i]).Y; } return(sum); }
public void AddPolygon(ThreeDPolygon aPolygon) { Polygons.Add(aPolygon); }