All pastes #282775 Raw Edit

Unnamed

public text v1 · immutable
#282775 ·published 2006-12-17 21:25 UTC
rendered paste body
   public abstract class Shape
    {
        #region Protected instance fields

        protected Point[] points;

        #endregion

        #region Public instance properties

        public Point[] Points
        {
            get { return points; }
            set { points = value; }
        } 

        #endregion

        public Shape(Point[] Points)
        {
            points = Points;
        }
        public Shape() 
        {
            points = null;
        }

        public void Transform(int Tx, int Ty, double Fi, double XScale,
            double YScale)
        {
            Scale(XScale, YScale);
            Rotate(Fi);
            Translate(Tx, Ty);
        }
        private void Translate(int Tx, int Ty)
        {
            for (int i = 0; i < Points.Length; i++)
            {
                points[i].X += Tx;
                points[i].Y += Ty;
            }
        }
        private void Scale(double XScale, double YScale)
        {
            for (int i = 0; i < points.Length; i++)
            {
                points[i].X = (int)(points[i].X * XScale);
                points[i].Y = (int)(points[i].Y * YScale);
            }
        }
        private void Rotate(double Fi)
        {
            Fi = Math.PI * Fi / 180;
            for (int i = 0; i < points.Length; i++)
            {
                double r = Math.Sqrt(Math.Pow(points[i].X, 2) + Math.Pow(points[i].Y, 2));
                double teta = Math.Asin(points[i].Y / r);
                teta = double.IsNaN(teta) ? 0 : teta;
                points[i].X = (int)(r * Math.Cos(teta + Fi));
                points[i].Y = (int)(r * Math.Sin(teta + Fi));
            }
        }

    }
}