Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Type Realization = EnterRealization();

            IVector3f current = EnterVector(Realization);

            int answer;

            do
            {
                answer = Ask(
                    "What you want to do?",
                    new List <string> {
                    "Exit",
                    "Change realization",
                    "Enter new vector",
                    "Print current vector",
                    "Print lenth of current vector",
                    "Calculate sum with another vector",
                    "Calculate difference with another vector",
                    "Calculate dot product with another vector",
                    "Calculate cos between this and another vector",
                });

                IVector3f another = null;
                switch (answer)
                {
                case 0: return;

                case 1:
                    Realization = EnterRealization();
                    current     = (IVector3f)Activator.CreateInstance(Realization, current.X, current.Y, current.Z);
                    break;

                case 2: current = EnterVector(Realization); break;

                case 3: Console.WriteLine($"Current vector is {current.ToString()}"); break;

                case 4: Console.WriteLine($"Current vector's lenght is {current.Lenght()}"); break;

                case 5:
                    another = EnterVector(Realization);
                    Console.WriteLine($"Sum of vectors {current} and {another} is {current.Sum(another)} ");
                    break;

                case 6:
                    another = EnterVector(Realization);
                    Console.WriteLine($"Difference of vectors {current} and {another} is {current.Diff(another)} ");
                    break;

                case 7:
                    another = EnterVector(Realization);
                    Console.WriteLine($"Dot product of vectors {current} and {another} is {current.Dot(another)} ");
                    break;

                case 8:
                    another = EnterVector(Realization);
                    Console.WriteLine($"Cosine between vectors {current} and {another} is {current.Cos(another)} ");
                    break;

                default: Console.WriteLine("Wrong answer!"); break;
                }
            } while (answer != 0);
        }
Ejemplo n.º 2
0
 public virtual float Cos(IVector3f other) => Dot(other) / (Lenght() * other.Lenght());