Example #1
0
        // Поворот с помощью кватерниона
        public TVector RotateByQuaternion(TQuaternion Q)
        {
            TVector     Result = new TVector(Vector);
            TQuaternion ResultQ;
            TQuaternion vector = new TQuaternion(0, this);

            ResultQ = Q.Mult(vector);
            ResultQ = ResultQ.Mult(Q.Conjugate());
            for (int i = 1; i < 4; i++)
            {
                Result.Vector[i - 1] = ResultQ.Vec[i];
            }
            return(Result);
        }
Example #2
0
        // Поворот на угол вокруг оси (через кватернионы)
        public TVector RotateByAngleOnAxis(double phi, TVector V)
        {
            TQuaternion Q = new TQuaternion(phi, V);

            Q = Q.Normalization();
            TQuaternion ThisVecQ = new TQuaternion(0, Vector[0], Vector[1], Vector[2]);
            TQuaternion ResultQ  = Q.Mult(ThisVecQ);

            ResultQ = ResultQ.Mult(Q.Conjugate());
            TVector Result = new TVector(Vector);

            for (int i = 1; i < 4; i++)
            {
                Result.Vector[i - 1] = ResultQ.Vec[i];
            }
            return(Result);
        }