Exemple #1
0
        public void AddPolygon(string line)
        {
            var             prs  = line.Split(' ').Select(x => x.Split(';').Select(z => Convert.ToDouble(z)).ToArray());
            List <PointPol> temp = new List <PointPol>();
            int             wh   = _form.pictureBox1.Width / 2;

            foreach (var y in prs)
            {
                PointPol t0 = new PointPol(y[0] + wh, y[1], y[2]);
                temp.Add(t0);
                if (vertices.Count == 0 || vertices.Any(v => v != t0))
                {
                    vertices.Add(t0);
                }
            }
            for (int i = 0; i < temp.Count - 1; ++i)
            {
                neighbors[temp[i]] = new List <PointPol>();
                neighbors[temp[i]].Add(temp[i + 1]);
            }
            neighbors[temp.Last()] = new List <PointPol>();
            neighbors[temp.Last()].Add(temp[0]);

            polygons.Add(new Polygon(temp));
        }
Exemple #2
0
        public PointPol rotate(Edge direction, double angle, double a, double b, double c)
        {
            double   phi = angle * Math.PI / 180;
            PointPol p   = shift(-a, -b, -c);

            double x1 = direction.P1.X;
            double y1 = direction.P1.Y;
            double z1 = direction.P1.Z;

            double x2 = direction.P2.X;
            double y2 = direction.P2.Y;
            double z2 = direction.P2.Z;

            double vecx = x2 - x1;
            double vecy = y2 - y1;
            double vecz = z2 - z1;

            double len = Math.Sqrt(vecx * vecx + vecy * vecy + vecz * vecz);

            double l = vecx / len;
            double m = vecy / len;
            double n = vecz / len;

            double[,] transfer = new double[4, 4] {
                { l *l + Math.Cos(phi) * (1 - l * l), l *(1 - Math.Cos(phi)) * m + n * Math.Sin(phi), l *(1 - Math.Cos(phi)) * n - m * Math.Sin(phi), 0 },
                { l *(1 - Math.Cos(phi)) * m - n * Math.Sin(phi), m *m + Math.Cos(phi) * (1 - m * m), m *(1 - Math.Cos(phi)) * n + l * Math.Sin(phi), 0 },
                { l *(1 - Math.Cos(phi)) * n + m * Math.Sin(phi), m *(1 - Math.Cos(phi)) * n - l * Math.Sin(phi), n *n + Math.Cos(phi) * (1 - n * n), 0 },
                { 0, 0, 0, 1 }
            };
            var t1 = _form.matrix_multiplication(p.getP(), transfer);

            t1 = _form.matrix_multiplication(t1, transfer);

            PointPol p2 = translatePol(t1);
            PointPol p3 = p2.shift(a, b, c);

            return(p3);
        }
Exemple #3
0
 public Edge(PointPol p1, PointPol p2)
 {
     P1 = p1; P2 = p2;
 }