Пример #1
0
        static float functionE()
        {
            //Inner(P,Q) = Px*Qx + Py*Qx + Pz*Qz
            _3DPoint P = new _3DPoint(1, 2, 3);
            _3DPoint Q = new _3DPoint(4, 5, 6);

            float part1 = P.getX() * Q.getX();
            float part2 = P.getY() * Q.getY();
            float part3 = P.getZ() * Q.getZ();
            float y     = part1 + part2 + part3;

            Console.WriteLine("Inner(P,Q) = Px*Qx + Py*Qx + Pz*Qz");
            Console.WriteLine("answer: " + y);
            return(y);
        }
Пример #2
0
        static float functionF()
        {
            //D(P, X0) = (a*x0 + b*y0 + c*z0 + d) / squareroot(a^2 + b^2 + c^2)
            _3DPoint X0 = new _3DPoint(1, 2, 3);
            Plane    P  = new Plane(4, 5, 6, 7);

            float part1 = P.getA() * X0.getX();
            float part2 = P.getB() * X0.getY();
            float part3 = P.getC() * X0.getZ();
            float part4 = part1 + part2 + part3 + P.getD();
            float part5 = Convert.ToSingle(Math.Pow(P.getA(), 2));
            float part6 = Convert.ToSingle(Math.Pow(P.getB(), 2));
            float part7 = Convert.ToSingle(Math.Pow(P.getC(), 2));
            float part8 = part5 + part6 + part7;
            float part9 = Convert.ToSingle(Math.Sqrt(part8));
            float y     = part4 / part9;

            Console.WriteLine("D(P, X0) = (a*x0 + b*y0 + c*z0 + d) / squareroot(a^2 + b^2 + c^2)");
            Console.WriteLine("answer: " + y);
            return(y);
        }