Example #1
0
        public void CosProjection(double alpha, double l, Pentagon pentagon, Cylinder cylinder, int N)
        {
            double[,] T;

            T = new double[4, 4] {
                { 1, 0, 0, 0 },
                { 0, 1, 0, 0 },
                { l *Math.Cos(alpha), l *Math.Sin(alpha), 0, 0 },
                { 0, 0, 0, 1 }
            };
            double[,] result = new double[1, 4] {
                { 0, 0, 0, 0 }
            };

            for (int i = 0; i < 6; i++)
            {
                double[,] s = new double[1, 4] {
                    { pentagon[i].X - xo, pentagon[i].Y - zo, pentagon[i].Z - yo, 1 }
                };
                result        = matrix.multiplyMatrixs(s, T);
                pentagon[i].X = result[0, 0] + xo;
                pentagon[i].Y = result[0, 1] + yo;
                pentagon[i].Z = result[0, 2] + zo;
            }
            result = new double[1, 4] {
                { 0, 0, 0, 0 }
            };
            for (int i = 0; i < 2 * N; i++)
            {
                double[,] s = new double[1, 4] {
                    { cylinder[i].X - xo, cylinder[i].Y - zo, cylinder[i].Z - yo, 1 }
                };
                result        = matrix.multiplyMatrixs(s, T);
                cylinder[i].X = result[0, 0] + xo;
                cylinder[i].Y = result[0, 1] + yo;
                cylinder[i].Z = result[0, 2] + zo;
            }
        }
Example #2
0
        public void AksProjection(double psi, double fi, Pentagon pentagon, Cylinder cylinder, int N)
        {
            double[,] T;

            T = new double[4, 4] {
                { Math.Cos(psi), Math.Sin(fi) * Math.Sin(psi), 0, 0 },
                { 0, Math.Cos(fi), 0, 0 },
                { Math.Sin(psi), -Math.Sin(fi) * Math.Cos(psi), 0, 0 },
                { 0, 0, 0, 1 }
            };
            double[,] result = new double[1, 4] {
                { 0, 0, 0, 0 }
            };

            for (int i = 0; i < 6; i++)
            {
                double[,] s = new double[1, 4] {
                    { pentagon[i].X - xo, pentagon[i].Y - zo, pentagon[i].Z - yo, 1 }
                };
                result        = matrix.multiplyMatrixs(s, T);
                pentagon[i].X = result[0, 0] + xo;
                pentagon[i].Y = result[0, 1] + yo;
                pentagon[i].Z = result[0, 2] + zo;
            }
            result = new double[1, 4] {
                { 0, 0, 0, 0 }
            };
            for (int i = 0; i < 2 * N; i++)
            {
                double[,] s = new double[1, 4] {
                    { cylinder[i].X - xo, cylinder[i].Y - zo, cylinder[i].Z - yo, 1 }
                };
                result        = matrix.multiplyMatrixs(s, T);
                cylinder[i].X = result[0, 0] + xo;
                cylinder[i].Y = result[0, 1] + yo;
                cylinder[i].Z = result[0, 2] + zo;
            }
        }
Example #3
0
        private void UseProjection(string projection, Pentagon pentagon, Cylinder cylinder)
        {
            switch (projection)
            {
            case "perspective":
                double d     = Double.Parse(textBox17.Text);
                double ro    = Double.Parse(textBox18.Text);
                double tetta = Double.Parse(textBox19.Text) * Math.PI / 180;
                double fi    = Double.Parse(textBox20.Text) * Math.PI / 180;
                formGraphics.Clear(BackColor);
                pentCopy = pentagon.DeepCopy();
                cylCopy  = cylinder.DeepCopy();
                new Projections(xo, yo, zo).PersProjection(d, ro, tetta, fi, pentCopy, cylCopy, _N);
                if (checkBox4.Checked)
                {
                    DrawWithoutLines(pentCopy, cylCopy);
                }
                else
                {
                    DrawCylinderXY(cylCopy);
                    DrawPentagonXY(pentCopy);
                }
                break;

            case "aks":
                double psi = Double.Parse(textBox3.Text) * Math.PI / 180;
                double fii = Double.Parse(textBox14.Text) * Math.PI / 180;
                formGraphics.Clear(BackColor);
                pentCopy = pentagon.DeepCopy();
                cylCopy  = cylinder.DeepCopy();
                new Projections(xo, yo, zo).AksProjection(psi, fii, pentCopy, cylCopy, _N);
                if (checkBox4.Checked)
                {
                    DrawWithoutLines(pentCopy, cylCopy);
                }
                else
                {
                    DrawCylinderXY(cylCopy);
                    DrawPentagonXY(pentCopy);
                }
                break;

            case "cos":
                double alpha = Double.Parse(textBox15.Text) * Math.PI / 180;
                double l     = Double.Parse(textBox16.Text);
                formGraphics.Clear(BackColor);
                pentCopy = pentagon.DeepCopy();
                cylCopy  = cylinder.DeepCopy();
                new Projections(xo, yo, zo).CosProjection(alpha, l, pentCopy, cylCopy, _N);
                if (checkBox4.Checked)
                {
                    DrawWithoutLines(pentCopy, cylCopy);
                }
                else
                {
                    DrawCylinderXY(cylCopy);
                    DrawPentagonXY(pentCopy);
                }
                break;

            default:
                if (checkBox1.Checked)
                {
                    DrawWithoutLines(pentCopy, cylCopy);
                }
                else
                {
                    DrawCylinderXY(cylCopy);
                    DrawPentagonXY(pentCopy);
                }
                break;
            }
        }
Example #4
0
        public void PersProjection(double d, double ro, double tetta, double fi, Pentagon pentagon, Cylinder cylinder, int N)
        {
            double[,] T;

            T = new double[4, 4] {
                { -Math.Sin(tetta), -Math.Cos(fi) * Math.Cos(tetta), -Math.Sin(fi) * Math.Cos(tetta), 0 },
                { Math.Cos(tetta), -Math.Cos(fi) * Math.Sin(tetta), -Math.Sin(fi) * Math.Cos(tetta), 0 },
                { 0, Math.Sin(fi), -Math.Cos(fi), 0 },
                { 0, 0, ro, 1 }
            };
            double[,] result = new double[1, 4] {
                { 0, 0, 0, 0 }
            };

            for (int i = 0; i < 6; i++)
            {
                double[,] s = new double[1, 4] {
                    { pentagon[i].X - xo, pentagon[i].Y - zo, pentagon[i].Z - yo, 1 }
                };
                result = matrix.multiplyMatrixs(s, T);
                if (result[0, 2] == 0)
                {
                    result[0, 2] = 0.1;
                }
                pentagon[i].X = result[0, 0] * d / result[0, 2] + xo;
                pentagon[i].Y = result[0, 1] * d / result[0, 2] + yo;
                pentagon[i].Z = result[0, 2] * d / result[0, 2] + zo;
            }

            result = new double[1, 4] {
                { 0, 0, 0, 0 }
            };
            for (int i = 0; i < 2 * N; i++)
            {
                double[,] s = new double[1, 4] {
                    { cylinder[i].X - xo, cylinder[i].Y - zo, cylinder[i].Z - yo, 1 }
                };
                result = matrix.multiplyMatrixs(s, T);
                if (result[0, 2] == 0)
                {
                    result[0, 2] = 0.1;
                }
                cylinder[i].X = result[0, 0] * d / result[0, 2] + xo;
                cylinder[i].Y = result[0, 1] * d / result[0, 2] + yo;
                cylinder[i].Z = result[0, 2] * d / result[0, 2] + zo;
            }
        }
Example #5
0
        public void Goriz(Pentagon pentagon, Cylinder cylinder, int N)
        {
            double an = 90 * Math.PI / 180;

            RotateX(an, pentagon, cylinder, N);
        }
Example #6
0
        public void Prof(Pentagon pentagon, Cylinder cylinder, int N)
        {
            double an = -90 * Math.PI / 180;

            RotateY(an, pentagon, cylinder, N);
        }
Example #7
0
 public void Front(Pentagon pentagon, Cylinder cylinder, int N)
 {
     RotateX(0, pentagon, cylinder, N);
     RotateY(0, pentagon, cylinder, N);
     RotateZ(0, pentagon, cylinder, N);
 }