Пример #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
        //Поворот фигуры на x РАДИАН
        public static Figure Rotation(Figure f, int angle)
        {
            double x   = Figure.ToRadian(angle);
            Figure res = new Figure();

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