示例#1
0
 //-------------------------------------------------------------------------------------------
 //Расстояния между точками массива и заданной точкой
 public static double[] GetDistances(Point3D[] points, Point3D targetPoint)
 {
     double[] distances = new double[points.Length];
     for (int index = 0; index < points.Length; index++)
     {
         Point3D point    = points[index];
         double  distance = SpaceManager.DistanceBetweenTwoPoints(point, targetPoint);
         distances[index] = distance;
     }
     return(distances);
 }
示例#2
0
        //----------------------------------------------------------------------------------------------
        //vector и auxiliaryVector задают плоскость, в которой
        //vector будет повернут на угол angle
        public static RealVector RotateVectorInPlane(
            RealVector vector, RealVector auxiliaryVector, double angle
            )
        {
            RealVector crossProductOne = SpaceManager.GetVectorsCrossProduct(vector, auxiliaryVector);
            RealVector crossProductTwo = SpaceManager.GetVectorsCrossProduct(vector, crossProductOne);
            RealVector newVector       =
                Math.Cos(angle) * vector + Math.Sin(angle) * crossProductTwo;

            return(newVector);
        }
示例#3
0
        //----------------------------------------------------------------------------------------------
        //Перемещение точек в первый октант
        public static Point3D[] DisplacePointsToFirstOctant(Point3D[] points)
        {
            double[] minimalCoordinates = SpaceManager.GetMinimalCoordinates(points);
            double   displacementX      = minimalCoordinates[0];
            double   displacementY      = minimalCoordinates[1];
            double   displacementZ      = minimalCoordinates[2];

            Point3D[] newPoints = SpaceManager.DisplacePoints
                                      (points, -displacementX, -displacementY, -displacementZ);

            return(newPoints);
        }
示例#4
0
        //----------------------------------------------------------------------------------------------
        //Максимальные координаты точек
        public static double[] GetMaximalCoordinates(Point3D[] points)
        {
            double[] coordinatesX = SpaceManager.GetCoordinatesX(points);
            double[] coordinatesY = SpaceManager.GetCoordinatesY(points);
            double[] coordinatesZ = SpaceManager.GetCoordinatesZ(points);

            double maxX = coordinatesX.Max();
            double maxY = coordinatesY.Max();
            double maxZ = coordinatesZ.Max();

            double[] maximalCoordinates = new double[] { maxX, maxY, maxZ };
            return(maximalCoordinates);
        }
示例#5
0
        //----------------------------------------------------------------------------------------------
        //Минимальные координаты точек
        public static double[] GetMinimalCoordinates(Point3D[] points)
        {
            double[] coordinatesX = SpaceManager.GetCoordinatesX(points);
            double[] coordinatesY = SpaceManager.GetCoordinatesY(points);
            double[] coordinatesZ = SpaceManager.GetCoordinatesZ(points);

            double minX = coordinatesX.Min();
            double minY = coordinatesY.Min();
            double minZ = coordinatesZ.Min();

            double[] minimalCoordinates = new double[] { minX, minY, minZ };
            return(minimalCoordinates);
        }
示例#6
0
 //----------------------------------------------------------------------------------------------
 //Повернуть векторы
 public static RealVector[] RotateVectors(
     RealVector[] vectors,
     RealMatrix rotationMatrix
     )
 {
     RealVector[] newVectors = new RealVector[vectors.Length];
     for (int index = 0; index < vectors.Length; index++)
     {
         RealVector vector    = vectors[index];
         RealVector newVector = SpaceManager.RotateVector(vector, rotationMatrix);
         newVectors[index] = newVector;
     }
     return(newVectors);
 }
示例#7
0
        //----------------------------------------------------------------------------------------------
        //Матрица поворота от вектора до заданного вектора
        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);
        }
        //-------------------------------------------------------------------------------------------
        //Расстояние до заданной точки
        public double GetDistanceToPoint(Point3D point)
        {
            double distance = SpaceManager.DistanceBetweenTwoPoints(this, point);

            return(distance);
        }