Beispiel #1
0
        //Ângulo Para Graus
        public double AngleToGraus(Vector3D Vec)
        {
            //Normalizando os vetores antes de calcular o produto escalar
            Vector3D VectorA;
            Vector3D VectorB;
            double   AngRad = 0;

            // do wpf
            VectorA = this;
            VectorB = Vec;

            double AdotB    = DotProduct(VectorA, VectorB);        //produto escalar
            double ALstarBL = VectorA.Length() * VectorB.Length(); //produto das normas

            //Normalizando o produto escalar
            if (ALstarBL == 0)
            {
                return(0.0);
            }

            //Return System.Math.Acos(AdotB / ALstarBL)

            if (System.Math.Acos(AdotB / ALstarBL) >= 0 && System.Math.Acos(AdotB / ALstarBL) <= 1.57)
            {
                //Se a medida angular esta no intervalo [0,Pi/2]  então angulo é entre os vetores A e B
                AngRad = System.Math.Acos(AdotB / ALstarBL);
            }
            else
            {
                if (System.Math.Acos(AdotB / ALstarBL) > 1.57 && System.Math.Acos(AdotB / ALstarBL) <= 3.14)
                {
                    //Se a medida angular esta no intervalo [0,Pi/2]  então angulo é entre os vetores A e B
                    AngRad = 3.14 - System.Math.Acos(AdotB / ALstarBL);
                }
            }

            //double angle = Math.Acos(dot_pro);          angle = angle * 180 / Math.PI;         angle = 180 - angle;
            //Returnig the value in graus
            return((AngRad * 180) / 3.14);
        }
Beispiel #2
0
        //ind the angle between this vector and the parameter vector
        public double AngleTo(Vector3D Vec)
        {
            //organizando os vetores antes de calcular o produto escalar
            Vector3D VectorA;
            Vector3D VectorB;

            VectorA = UnitVector();
            VectorB = Vec.UnitVector();


            double AdotB    = DotProduct(VectorA, VectorB);        //produto escalar
            double ALstarBL = VectorA.Length() * VectorB.Length(); //produto das normas

            //Normalizando o produto escalar

            if (ALstarBL == 0)
            {
                return(0.0);
            }
            return(System.Math.Acos(AdotB / ALstarBL));

            //double angle = Math.Acos(dot_pro);          angle = angle * 180 / Math.PI;         angle = 180 - angle;
        }