Exemplo n.º 1
0
        private void Displacement(double kx, double ky, double kz) // сдвиг
        {
            Matrix transform = Transformations.Translate(kx, ky, kz);

            foreach (Vector p in shape_points)
            {
                p.updateFromVector(transform.Multiple(p.getVector()));
            }
        }
Exemplo n.º 2
0
        private void Scaling(double xScale, double yScale, double zScale) // масштабирование
        {
            Vector center_P = CenterPoint();

            Matrix scale  = Transformations.Scale(xScale, yScale, zScale);
            Matrix displ1 = Transformations.Translate(-center_P.X, -center_P.Y, -center_P.Z);
            Matrix displ2 = Transformations.Translate(center_P.X, center_P.Y, center_P.Z);

            foreach (Vector p in shape_points)
            {
                p.updateFromVector(displ1.Multiple(p.getVector()));
                p.updateFromVector(scale.Multiple(p.getVector()));
                p.updateFromVector(displ2.Multiple(p.getVector()));
            }
        }
Exemplo n.º 3
0
        private void Rotate(double xangle, double yangle, double zangle) // поворот
        {
            Matrix mx        = Transformations.RotateX(xangle);
            Matrix my        = Transformations.RotateY(yangle);
            Matrix mz        = Transformations.RotateZ(zangle);
            Matrix transform = mx.Multiple(my).Multiple(mz);

            foreach (Vector p in shape_points)
            {
                p.updateFromVector(transform.Multiple(p.getVector()));
                //p.updateFromVector(mx.Multiple(p.getVector()));
                //p.updateFromVector(my.Multiple(p.getVector()));
                //p.updateFromVector(mz.Multiple(p.getVector()));
            }
        }
Exemplo n.º 4
0
        private void CreateRotationFigure(object sender, EventArgs e)
        {
            shape.Clear();
            int    count = (int)countRotation.Value;
            double angle = (360 / count * Math.PI) / 180;
            Matrix m     = Transformations.RotateY(angle);

            for (int c = 0; c < count; c++)
            {
                List <Vector> nextPoints = new List <Vector>();
                for (int i = 0; i < points.Count; i++)
                {
                    Vector p = new Vector();
                    p.updateFromVector(m.Multiple(points[i].getVector()));
                    nextPoints.Add(p);
                }
                for (int i = 1; i < points.Count; i++)
                {
                    Face f = new Face();
                    f.add(points[i - 1]);
                    f.add(points[i]);
                    f.add(nextPoints[i - 1]);

                    Face f1 = new Face();
                    f1.add(points[i]);
                    f1.add(nextPoints[i]);
                    f1.add(nextPoints[i - 1]);
                    f.color = Color.Blue;
                    shape.Add(f);
                    shape.Add(f1);
                }
                points = nextPoints;
            }
            points.Clear();
            BuildPoints();
            RedrawImage();
        }