Esempio n. 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)
        public static List <PointR> ScaleOrientedTo(List <PointR> points, SizeR sz)
        {
            var radians = AngleInRadians(Centroid(points), points[0], false); // indicative angle
            //ArrayList newpoints = RotateByRadians(points, -radians); // rotate so that centroid-to-point[0] is 0 deg.
            var 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);
        }
Esempio n. 2
0
        // translates the points by the given delta amounts
        //public static ArrayList TranslateBy(ArrayList points, SizeR sz)
        public static List <PointR> TranslateBy(List <PointR> points, SizeR sz)
        {
            //ArrayList newPoints = new ArrayList(points.Count);
            var newPoints = new List <PointR>(points.Count);

            for (var i = 0; i < points.Count; i++)
            {
                var p = points[i];
                p.X += sz.Width;
                p.Y += sz.Height;
                newPoints.Add(p);
            }
            return(newPoints);
        }
Esempio n. 3
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)
        public static List <PointR> ScaleTo(List <PointR> points, SizeR sz)
        {
            //ArrayList newPoints = new ArrayList(points.Count);
            var newPoints = new List <PointR>(points.Count);
            var r         = FindBox(points);

            for (var i = 0; i < points.Count; i++)
            {
                var p = 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);
        }
Esempio n. 4
0
 // copy constructor
 public SizeR(SizeR sz)
 {
     _cx = sz.Width;
     _cy = sz.Height;
 }