示例#1
0
文件: Program.cs 项目: Scdk/OOP
        static void Main(string[] args)
        {
            // Criando e preenchendo os atributos
            int x;
            int y;
            int z;

            Console.WriteLine("Preencha o x do primeiro vetor: ");
            x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Preencha o y do primeiro vetor: ");
            y = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Preencha o z do primeiro vetor: ");
            z = Convert.ToInt32(Console.ReadLine());
            Vetor3D r1 = new Vetor3D(x, y, z);

            Console.WriteLine("\nPreencha o x do segundo vetor: ");
            x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Preencha o y do segundo vetor: ");
            y = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Preencha o z do segundo vetor: ");
            z = Convert.ToInt32(Console.ReadLine());
            Vetor3D r2 = new Vetor3D(x, y, z);

            // Usando os métodos
            Console.WriteLine("\nModulo do vetor 3D: " + Math.Round(r1.modulo3D(), 2));
            Console.WriteLine("Multiplicação de dois vetores:\n" + "X: " + (r1.multiplicaVetor(r2).getX()) + "\nY: " + r1.multiplicaVetor(r2).getY() + "\nZ: "
                              + r1.multiplicaVetor(r2).getZ());
        }
示例#2
0
        static void Main(string[] args)
        {
            Vetor3D v0 = new Vetor3D();
            Vetor3D v1 = new Vetor3D(15, 27, 06);
            Vetor3D v2 = new Vetor3D(09, 52, 12);
            Vetor3D i  = new Vetor3D(1, 0, 0);
            Vetor3D j  = new Vetor3D(0, 1, 0);
            Vetor3D k  = new Vetor3D(0, 0, 1);


            Console.WriteLine(
                "Vetor i: " + i.print() + "\n" +
                "Vetor j: " + j.print() + "\n" +
                "Vetor k: " + k.print() + "\n" +
                "Vetor V0: " + v0.print() + "\n" +
                "Vetor V1: " + v1.print() + "\n" +
                "Vetor V2: " + v2.print() + "\n" +
                "Módulo de i: " + i.modulo() + "\n" +
                "Módulo de j: " + j.modulo() + "\n" +
                "Módulo de k: " + k.modulo() + "\n" +
                "Módulo de V0: " + v0.modulo() + "\n" +
                "Módulo de V1: " + v1.modulo() + "\n" +
                "Módulo de V2: " + v2.modulo() + "\n" +
                "V0 vetorial V1: " + v0.vetorial(v1).print() + "\n" +
                "V1 vetorial V0: " + v1.vetorial(v0).print() + "\n" +
                "V1 vetorial V2: " + v1.vetorial(v2).print() + "\n" +
                "V2 vetorial V1: " + v2.vetorial(v1).print() + "\n" +
                "i vetorial j: " + i.vetorial(j).print() + "\n" +
                "j vetorial i: " + j.vetorial(i).print());


            Console.ReadLine();
        }
示例#3
0
 public Vetor3D vetorial(Vetor3D _b)
 {
     return(new Vetor3D(
                (y * _b.getZ() - z * _b.getY()),
                (z * _b.getX() - x * _b.getZ()),
                (x * _b.getY() - y * _b.getX())));
 }
示例#4
0
        public Vetor3D prodVetorial(Vetor3D vetor3D)
        {
            Vetor3D vetor = new Vetor3D(y * vetor3D.z - z * vetor3D.y,
                                        z * vetor3D.x - x * vetor3D.z,
                                        x * vetor3D.y - y * vetor3D.x);

            return(vetor);
        }
示例#5
0
文件: Vetor3D.cs 项目: Scdk/OOP
        public Vetor3D multiplicaVetor(Vetor3D r2)
        {
            Vetor3D r3 = new Vetor3D();

            r3.setX((y * r2.getZ()) - (r2.getY() * z));
            r3.setY((r2.getX() * z) - (x * r2.getZ()));
            r3.setZ((x * r2.getY()) - (r2.getX() * y));
            return(r3);
        }
示例#6
0
        public Vetor3D Vetorial(Vetor3D b)
        {
            Vetor3D p = new Vetor3D();

            p.x = (y * b.z) - (z * b.y);
            p.y = (z * b.x) - (x * b.z);
            p.z = (x * b.y) - (y * b.x);

            return(p);
        }
示例#7
0
        static void Main(string[] args)
        {
            Vetor3D vetA = new Vetor3D(5, 3, 1);
            Vetor3D vetB = new Vetor3D(1, -1, 0);

            Console.WriteLine("A = " + vetA.imprimeVetor());
            Console.WriteLine("B = " + vetB.imprimeVetor());

            Console.WriteLine("\nProduto vetorial dos vetores A x B: " + vetA.prodVetorial(vetB).imprimeVetor());

            Console.WriteLine("\nMódulo do vetor A: " + vetA.norma());
            Console.WriteLine("Módulo do vetor B: " + vetB.norma());

            Console.ReadLine();
        }
示例#8
0
        static void Main(string[] args)
        {
            Vetor3D a = new Vetor3D();
            Vetor3D b = new Vetor3D();
            Vetor3D c = new Vetor3D();

            Console.WriteLine("Digite a componente x do vetor B:");
            b.setX(Convert.ToDouble(Console.ReadLine()));
            Console.WriteLine("Digite a componente y do vetor B:");
            b.setY(Convert.ToDouble(Console.ReadLine()));
            Console.WriteLine("Digite a componente z do vetor B:");
            b.setZ(Convert.ToDouble(Console.ReadLine()));

            Console.WriteLine("Modulo do vetor a: " + a.Modulo3D());
            Console.WriteLine("Modulo do vetor b: " + b.Modulo3D());
            c = a.Vetorial(b);
            Console.WriteLine("O produto vetorial de a e b é: (" + c.getX() + ", " + c.getY() + ", " + c.getZ() + ")");
            Console.ReadLine();
        }