//---------------------------------------------------------------------------------------------- //Матрица поворота от вектора до заданного вектора public static RealMatrix GetRotationMatrixToTargetVector( RealVector vector, RealVector targetVector ) { RealVector crossProduct = SpaceManager.GetVectorsCrossProduct(vector, targetVector); RealVector normalizedCrossProduct = (1 / crossProduct.Length) * crossProduct; double angle = SpaceManager.GetAngleBetweenVectors(vector, targetVector); double x = normalizedCrossProduct[0]; double y = normalizedCrossProduct[1]; double z = normalizedCrossProduct[2]; double[ , ] arrayA = new double[, ] { { 0, -z, y }, { z, 0, -x }, { -y, x, 0 } }; RealMatrix matrixA = new RealMatrix(arrayA); RealMatrix rotationMatrix = RealMatrix.IdentityMatrix(3) + matrixA * Math.Sin(angle) + (matrixA * matrixA) * (1 - Math.Cos(angle)); return(rotationMatrix); }