コード例 #1
0
        //Поворот фигуры вокруг точки
        public static Figure RotationPoint(Figure f, CustomPoint p, int angle)
        {
            double x = Figure.ToRadian(angle);

            if (f.points.Count != 2)
            {
                throw new Exception("This is not line");
            }
            CustomPoint p1  = f.points[0];
            CustomPoint p2  = f.points[1];
            Figure      res = new Figure();
            CustomPoint tmp = p;

            p1 = CustomPoint.Displacement(p1, (int)((-1) * tmp.x), (int)((-1) * tmp.y));
            p2 = CustomPoint.Displacement(p2, (int)((-1) * tmp.x), (int)((-1) * tmp.y));

            p1 = CustomPoint.Rotation(p1, x);
            p2 = CustomPoint.Rotation(p2, x);

            p1 = CustomPoint.Displacement(p1, (int)tmp.x, (int)tmp.y);
            p2 = CustomPoint.Displacement(p2, (int)tmp.x, (int)tmp.y);

            res.Add(p1);
            res.Add(p2);
            return(res);
        }
コード例 #2
0
        //Параллельное смещение фигуры
        public static Figure Displacement(Figure f, int x, int y)
        {
            Figure res = new Figure();

            for (int i = 0; i < f.points.Count; i++)
            {
                res.Add(CustomPoint.Displacement(f.points[i], x, y));
            }
            return(res);
        }