//------------------------------------------------------------------------------------------- //Расстояния между точками массива и заданной точкой 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); }
//---------------------------------------------------------------------------------------------- //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); }
//---------------------------------------------------------------------------------------------- //Перемещение точек в первый октант 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); }
//---------------------------------------------------------------------------------------------- //Максимальные координаты точек 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); }
//---------------------------------------------------------------------------------------------- //Минимальные координаты точек 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); }
//---------------------------------------------------------------------------------------------- //Повернуть векторы 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); }
//---------------------------------------------------------------------------------------------- //Матрица поворота от вектора до заданного вектора 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); }