Ejemplo n.º 1
0
        public static void Main()
        {
            Console.WriteLine("v1=(1,1,-2.4)");
             Vector3 v1 = new Vector3(1,1,-2.4);
             Console.WriteLine("v2=(4,5,6)");
             Vector3 v2 = new Vector3(4,5,6);
             Console.WriteLine("v3=(-1,5,2)");
             Vector3 v3 = new Vector3(-1,3,-2);
             Console.Write("v1*v2=");
             Vector3.CrossProduct(v1,v2).Vypis();
             Console.Write("v1.v2=");
             Console.WriteLine(Vector3.DotProduct(v1,v2));
             Console.Write("v1+v2=");
             (v1+v2).Vypis();
             Console.Write("v1-v2=");
             (v1+v2).Vypis();
             Console.Write("|v1|=");
             Console.WriteLine(v1.Abs());

             Console.WriteLine("Normala plochy v1 v2 v3");
             Vector3.GetNormVect(v1,v2,v3).Vypis();

             Console.WriteLine("v1 perspektiva");
              Projection p = new Projection((double)Math.PI/4,1,2.4,66);
              p.Project(v1).Vypis();
              Console.WriteLine("Rozmery projekcni plochy:{0},{1}",p.Width,p.Height);
              Vector3 v4 = p.Project(v1);
              Console.WriteLine("z original = -2.4, z projected = {0}",p.ProjectZ(-2.4));
              Console.WriteLine("projekceXY v1");
              p.ProjectXY(v1).Vypis();

              Viewport port = new Viewport(p.Width,p.Height,200,200);
              Console.WriteLine("souradnice v1 na obrazovce 200X200={0},{1}",
                    port.GetIntX(v4.X),port.GetIntY(v4.Y));
              Console.WriteLine("v2d=(1,2),sirka obrazovky = 2,rozliseni x = 200");
              Vector2 v2d = new Vector2(1,2);
              int x = v2d.GetIntX(2,200);
              Console.WriteLine("x souradnice bodu na obrazovce={0}",x);
              Console.WriteLine("v2d=(-1,2),sirka obrazovky = 2,rozliseni x = 200");
              v2d = new Vector2(-1,2);
              x = v2d.GetIntX(2,200);
              Console.WriteLine("x souradnice bodu na obrazovce={0}",x);
              Console.WriteLine("v2d=(0,2),sirka obrazovky = 2,rozliseni x = 200");
              v2d = new Vector2(0,2);
              x = v2d.GetIntX(2,200);
              Console.WriteLine("x souradnice bodu na obrazovce={0}",x);

              Console.WriteLine("Trojuhelnik abc ma vrcholy v1,v2,v3");
              Triangle3D abc = new Triangle3D(v1,v2,v3);
              Console.WriteLine("normalovy vektor k rovine trojuhelniku je");
              abc.GetNormVect().Vypis();

              Matrix44 matrix1 = new Matrix44(new double[,]{{1,2,3,4},{5,6,7,8},
                        {9,10,11,12},{13,14,15,16}});
              Matrix44 matrix2 = new Matrix44(new double[,]{{3,2,1,0},{0,1,2,3},
                          {6,8,7,4},{2,3,1,9}});
            Console.WriteLine("m1=");
            matrix1.Vypis();
            Console.WriteLine("m2=");
            matrix2.Vypis();
            Console.WriteLine("m1*m2=");
            Matrix44.Multiply(matrix1,matrix2).Vypis();

            Console.WriteLine("Zkouska trideni");
            v1.Vypis();
            v2.Vypis();
            v3.Vypis();

            Vector3.SortX(ref v1,ref v2,ref v3);

            Console.WriteLine("Setrideno podle x:");
            v1.Vypis();
            v2.Vypis();
            v3.Vypis();

            Console.WriteLine("Line2D getx gety");
            Line2D line2d = new Line2D(v1,v2);
            Console.WriteLine(line2d.GetX(0));
            Console.WriteLine(line2d.GetY(0));

            Line3D line3d = new Line3D(v1,v3);
            v4 = new Vector3(line3d.GetX(v2.Y),v2.Y,line3d.GetZFromY(v2.Y));
            v1.Vypis();
            v2.Vypis();
            v3.Vypis();
            v4.Vypis();

            Console.WriteLine("interpolace:");
            for(int i = 0;i<10;i++)
              line3d.Interpolate((double)i/(double)10).Vypis();
        }