Example #1
0
        /// <summary>
        /// Scales the bounding box defined by a set of points after first rotating that set
        /// such that the angle from centroid-to-first-point is zero degrees. After scaling,
        /// the points are rotated back by the same angle.
        /// </summary>
        /// <param name="points"></param>
        /// <param name="sz"></param>
        /// <returns></returns>
        public static ArrayList ScaleOrientedTo(ArrayList points, SizeR sz)
        {
            double    radians   = AngleInRadians(Centroid(points), (PointR)points[0], false); // indicative angle
            ArrayList newpoints = RotateByRadians(points, -radians);                          // rotate so that centroid-to-point[0] is 0 deg.

            newpoints = ScaleTo(newpoints, sz);
            newpoints = RotateByRadians(newpoints, +radians); // restore orientation
            return(newpoints);
        }
Example #2
0
 public override bool Equals(object obj)
 {
     if (obj is SizeR)
     {
         SizeR sz = (SizeR)obj;
         return(Width == sz.Width && Height == sz.Height);
     }
     return(false);
 }
Example #3
0
        // translates the points by the given delta amounts
        public static ArrayList TranslateBy(ArrayList points, SizeR sz)
        {
            ArrayList newPoints = new ArrayList(points.Count);

            for (int i = 0; i < points.Count; i++)
            {
                PointR p = (PointR)points[i];
                p.X += sz.Width;
                p.Y += sz.Height;
                newPoints.Add(p);
            }
            return(newPoints);
        }
Example #4
0
        // scales by the percentages contained in the 'sz' parameter. values of 1.0 would result in the
        // identity scale (that is, no change).
        public static ArrayList ScaleBy(ArrayList points, SizeR sz)
        {
            ArrayList  newPoints = new ArrayList(points.Count);
            RectangleR r         = FindBox(points);

            for (int i = 0; i < points.Count; i++)
            {
                PointR p = (PointR)points[i];
                p.X *= sz.Width;
                p.Y *= sz.Height;
                newPoints.Add(p);
            }
            return(newPoints);
        }
Example #5
0
        // scales the points so that they form the size given. does not restore the
        // origin of the box.
        public static ArrayList ScaleTo(ArrayList points, SizeR sz)
        {
            ArrayList  newPoints = new ArrayList(points.Count);
            RectangleR r         = FindBox(points);

            for (int i = 0; i < points.Count; i++)
            {
                PointR p = (PointR)points[i];
                if (r.Width != 0.0)
                {
                    p.X *= (sz.Width / r.Width);
                }
                if (r.Height != 0.0)
                {
                    p.Y *= (sz.Height / r.Height);
                }
                newPoints.Add(p);
            }
            return(newPoints);
        }
Example #6
0
 // copy constructor
 public SizeR(SizeR sz)
 {
     _cx = sz.Width;
     _cy = sz.Height;
 }
Example #7
0
		// copy constructor
		public SizeR(SizeR sz)
		{
			_cx = sz.Width;
			_cy = sz.Height;
		}
Example #8
0
 // scales by the percentages contained in the 'sz' parameter. values of 1.0 would result in the
 // identity scale (that is, no change).
 public static ArrayList ScaleBy(ArrayList points, SizeR sz)
 {
     ArrayList newPoints = new ArrayList(points.Count);
     RectangleR r = FindBox(points);
     for (int i = 0; i < points.Count; i++)
     {
         PointR p = (PointR) points[i];
         p.X *= sz.Width;
         p.Y *= sz.Height;
         newPoints.Add(p);
     }
     return newPoints;
 }
Example #9
0
 // scales the points so that they form the size given. does not restore the 
 // origin of the box.
 public static ArrayList ScaleTo(ArrayList points, SizeR sz)
 {
     ArrayList newPoints = new ArrayList(points.Count);
     RectangleR r = FindBox(points);
     for (int i = 0; i < points.Count; i++)
     {
         PointR p = (PointR) points[i];
         if (r.Width != 0.0)
             p.X *= (sz.Width / r.Width);
         if (r.Height != 0.0)
             p.Y *= (sz.Height / r.Height);
         newPoints.Add(p);
     }
     return newPoints;
 }
Example #10
0
 /// <summary>
 /// Scales the bounding box defined by a set of points after first rotating that set
 /// such that the angle from centroid-to-first-point is zero degrees. After scaling,
 /// the points are rotated back by the same angle.
 /// </summary>
 /// <param name="points"></param>
 /// <param name="sz"></param>
 /// <returns></returns>
 public static ArrayList ScaleOrientedTo(ArrayList points, SizeR sz)
 {
     double radians = AngleInRadians(Centroid(points), (PointR) points[0], false); // indicative angle
     ArrayList newpoints = RotateByRadians(points, -radians); // rotate so that centroid-to-point[0] is 0 deg.
     newpoints = ScaleTo(newpoints, sz);
     newpoints = RotateByRadians(newpoints, +radians); // restore orientation
     return newpoints;
 }
Example #11
0
 // translates the points by the given delta amounts
 public static ArrayList TranslateBy(ArrayList points, SizeR sz)
 {
     ArrayList newPoints = new ArrayList(points.Count);
     for (int i = 0; i < points.Count; i++)
     {
         PointR p = (PointR) points[i];
         p.X += sz.Width;
         p.Y += sz.Height;
         newPoints.Add(p);
     }
     return newPoints;
 }