示例#1
0
        /// <summary>
        /// Returns a list of regular polygon's vertices, which has a
        /// specified amount of sides and is inscribed into
        /// a circle of certain radius and center point.
        ///
        /// The first vertice will be located at specified angle (counting counterclockwise)
        /// from the circle's rightmost point.
        /// </summary>
        /// <param name="sideCount">The total amount of polygon's sides. May be equal to 2 (then the resulting vertices will make up a line).</param>
        /// <param name="circleCenter">The center of the surrounding circle.</param>
        /// <param name="circleRadius">The radius of the surrounding circle.</param>
        /// <param name="initialAngle">The angle (in radians, counting counterclockwise from the circle's rightmost point) at which the first vertice will be located.</param>
        /// <returns>The list of regular polygon's vertices.</returns>
        public static List <PointD> RegularPolygonInscribedIntoCircle(int sideCount, PointD circleCenter, double circleRadius, double initialAngle = 0)
        {
            // Вектор в ноль градусов.
            VectorD initialVector = new VectorD(circleCenter, new PointD(circleCenter.X + circleRadius, circleCenter.Y));

            List <PointD> points = new List <PointD>(sideCount);

            // Вектор установлен на начальный угол.

            if (initialAngle != 0)
            {
                initialVector = initialVector.VectorRotatedNewStartPoint(initialAngle, initialVector.StartPoint);
            }

            points.Add(initialVector.EndPoint);

            double rotationAngle = 2 * Math.PI / sideCount;

            VectorD currentVector;

            for (int i = 1; i < sideCount; i++)
            {
                currentVector = initialVector.VectorRotatedNewStartPoint(i * rotationAngle, initialVector.StartPoint);
                points.Add(currentVector.EndPoint);
            }

            return(points);
        }
示例#2
0
        /// <summary>
        /// Returns a list of regular polygon's vertices, which has a 
        /// specified amount of sides and is inscribed into
        /// a circle of certain radius and center point.
        /// 
        /// The first vertice will be located at specified angle (counting counterclockwise)
        /// from the circle's rightmost point.
        /// </summary>
        /// <param name="sideCount">The total amount of polygon's sides. May be equal to 2 (then the resulting vertices will make up a line).</param>
        /// <param name="circleCenter">The center of the surrounding circle.</param>
        /// <param name="circleRadius">The radius of the surrounding circle.</param>
        /// <param name="initialAngle">The angle (in radians, counting counterclockwise from the circle's rightmost point) at which the first vertice will be located.</param>
        /// <returns>The list of regular polygon's vertices.</returns>
        public static List<PointD> RegularPolygonInscribedIntoCircle(int sideCount, PointD circleCenter, double circleRadius, double initialAngle = 0)
        {
            // Вектор в ноль градусов.
            VectorD initialVector = new VectorD(circleCenter, new PointD(circleCenter.X + circleRadius, circleCenter.Y));

            List<PointD> points = new List<PointD>(sideCount);

            // Вектор установлен на начальный угол.
            
            if(initialAngle != 0)
                initialVector = initialVector.VectorRotatedNewStartPoint(initialAngle, initialVector.StartPoint);
    
            points.Add(initialVector.EndPoint);

            double rotationAngle = 2 * Math.PI / sideCount;

            VectorD currentVector;

            for(int i=1; i<sideCount; i++)
            {
                currentVector = initialVector.VectorRotatedNewStartPoint(i * rotationAngle, initialVector.StartPoint);
                points.Add(currentVector.EndPoint);
            }

            return points;
        }
示例#3
0
        /// <summary>
        /// Returns the angle, in radians, that is required by the first vector
        /// to be rotated counterclockwise to become collinear with the second.
        /// </summary>
        /// <param name="first">The first vector.</param>
        /// <param name="second">The second vector.</param>
        /// <returns>
        /// The angle, in radians, that is required by the first vector
        /// to be rotated counterclockwise to become collinear with the second.
        /// </returns>
        public static double angleBetweenVectors(VectorD first, VectorD second)
        {
            double x1 = first.X;
            double y1 = first.Y;
            double x2 = second.X;
            double y2 = second.Y;

            return(Math.Atan2(x1 * y2 - y1 * x2, x1 * x2 + y1 * y2));
        }
示例#4
0
        /// <summary>
        /// Returns the Matrix for the Affine transformation that 
        /// transforms one vector to another taking their starting points into account.
        /// </summary>
        /// <param name="firstVector">The first vector.</param>
        /// <param name="secondVector">The second vector.</param>
        /// <param name="equationSystemSolverFunction">The function that, being provided with matrix 
        /// square matrix of size N (containing the unknown parameters' coefficients) and a vector of 
        /// free terms having length N, will return the vector of unknown parameters.
        /// May be null, an internal function will be used in this case.
        /// </param>
        /// <param name="c">The first free term of transformation matrix. Can be set to any value, affects the inverse matrix calculation precision.</param>
        /// <param name="d">THe second free term of transformation matrix. Can be set to any value, affects the inverse matrix calculation precision.</param>
        /// <returns>An affine transform matrix that would convert the <paramref name="firstVector"/> to the <paramref name="secondVector"/>.</returns>
        public static Matrix_SDA<double, CalcDouble> GetAffineTransformMatrix(
            VectorD firstVector, 
            VectorD secondVector, 
            double c = 0, 
            double d = 0,
            Func<DoubleMatrix, DoubleVector, DoubleVector> equationSystemSolverFunction = null)
        {
            if(equationSystemSolverFunction == null)
                equationSystemSolverFunction = delegate(DoubleMatrix matrix, DoubleVector f)
                {
                    // Используется алгоритм нахождения обратной матрицы.
                    DoubleMatrix inverse = matrix.inverseMatrix_LUP_Factorization();

                    return null;
                };

            return null;
        }
示例#5
0
        /// <summary>
        /// Returns the Matrix for the Affine transformation that
        /// transforms one vector to another taking their starting points into account.
        /// </summary>
        /// <param name="firstVector">The first vector.</param>
        /// <param name="secondVector">The second vector.</param>
        /// <param name="equationSystemSolverFunction">The function that, being provided with matrix
        /// square matrix of size N (containing the unknown parameters' coefficients) and a vector of
        /// free terms having length N, will return the vector of unknown parameters.
        /// May be null, an internal function will be used in this case.
        /// </param>
        /// <param name="c">The first free term of transformation matrix. Can be set to any value, affects the inverse matrix calculation precision.</param>
        /// <param name="d">THe second free term of transformation matrix. Can be set to any value, affects the inverse matrix calculation precision.</param>
        /// <returns>An affine transform matrix that would convert the <paramref name="firstVector"/> to the <paramref name="secondVector"/>.</returns>
        public static Matrix_SDA <double, CalcDouble> GetAffineTransformMatrix(
            VectorD firstVector,
            VectorD secondVector,
            double c = 0,
            double d = 0,
            Func <DoubleMatrix, DoubleVector, DoubleVector> equationSystemSolverFunction = null)
        {
            if (equationSystemSolverFunction == null)
            {
                equationSystemSolverFunction = delegate(DoubleMatrix matrix, DoubleVector f)
                {
                    // Используется алгоритм нахождения обратной матрицы.
                    DoubleMatrix inverse = matrix.inverseMatrix_LUP_Factorization();

                    return(null);
                }
            }
            ;

            return(null);
        }
    }
示例#6
0
 /// <summary>
 /// Returns the sine of the angle between two vectors.
 /// </summary>
 /// <param name="first">The first vector.</param>
 /// <param name="second">The second vector.</param>
 /// <returns>
 /// The sine of the angle that is required by the first vector to be
 /// rotated counterclockwise to become collinear with the second.
 /// </returns>
 public static double angleSinBetweenVectors(VectorD first, VectorD second)
 {
     return((first.multiplyWedge(second)) / (first.Length * second.Length));
 }
示例#7
0
        // --------------------------------------------
        // ---------------- STATIC MATHS --------------

        /// <summary>
        /// Returns the cosine of the angle between two vectors.
        /// </summary>
        /// <param name="first">The first vector.</param>
        /// <param name="second">The second vector.</param>
        /// <returns>The cosine of the angle between vectors.</returns>
        public static double angleCosBetweenVectors(VectorD first, VectorD second)
        {
            return((first.multiplyScalar(second)) / (first.Length * second.Length));
        }
示例#8
0
 /// <summary>
 /// Returns the wedge product of
 /// two vectors.
 ///
 /// The wedge product of vectors A and B is equal to the value |A|*|B|*sin(phi),
 /// where phi is the angle of rotating A to B counterclockwise to become collinear.
 /// </summary>
 /// <param name="another">Another vector to find the wedge product between the current vector and the specified.</param>
 /// <returns>The wedge product of two vectors.</returns>
 public double multiplyWedge(VectorD another)
 {
     return(this.X * another.Y - this.Y * another.X);
 }
示例#9
0
        // ---------------------------------
        // ---------- multiplication -------
        // ---------------------------------

        /// <summary>
        /// Returns the scalar product of two vectors.
        ///
        /// The scalar product of vectors A and B is equal to the value |A|*|B|*sin(phi),
        /// where phi is the angle between A to B.
        /// </summary>
        /// <param name="another">Another vector to find the scalar product to find the scalar product between the current vector and the specified.</param>
        /// <returns>The scalar product of two vectors.</returns>
        public double multiplyScalar(VectorD another)
        {
            return(this.X * another.X + this.Y * another.Y);
        }
示例#10
0
        /// <summary>
        /// Returns the angle, in radians, that is required by the first vector
        /// to be rotated counterclockwise to become collinear with the second.
        /// </summary>
        /// <param name="first">The first vector.</param>
        /// <param name="second">The second vector.</param>
        /// <returns>
        /// The angle, in radians, that is required by the first vector
        /// to be rotated counterclockwise to become collinear with the second.
        /// </returns>
        public static double angleBetweenVectors(VectorD first, VectorD second)
        {
            double x1 = first.X;
            double y1 = first.Y;
            double x2 = second.X;
            double y2 = second.Y;

            return Math.Atan2(x1 * y2 - y1 * x2, x1 * x2 + y1 * y2);
        }
示例#11
0
 /// <summary>
 /// Returns the sine of the angle between two vectors.
 /// </summary>
 /// <param name="first">The first vector.</param>
 /// <param name="second">The second vector.</param>
 /// <returns>
 /// The sine of the angle that is required by the first vector to be 
 /// rotated counterclockwise to become collinear with the second.
 /// </returns>
 public static double angleSinBetweenVectors(VectorD first, VectorD second)
 {
     return (first.multiplyWedge(second)) / (first.Length * second.Length);
 }
示例#12
0
        // --------------------------------------------
        // ---------------- STATIC MATHS --------------

        /// <summary>
        /// Returns the cosine of the angle between two vectors.
        /// </summary>
        /// <param name="first">The first vector.</param>
        /// <param name="second">The second vector.</param>
        /// <returns>The cosine of the angle between vectors.</returns>
        public static double angleCosBetweenVectors(VectorD first, VectorD second)
        {
            return (first.multiplyScalar(second)) / (first.Length * second.Length);
        }
示例#13
0
 /// <summary>
 /// Returns the wedge product of
 /// two vectors.
 /// 
 /// The wedge product of vectors A and B is equal to the value |A|*|B|*sin(phi),
 /// where phi is the angle of rotating A to B counterclockwise to become collinear.
 /// </summary>
 /// <param name="another">Another vector to find the wedge product between the current vector and the specified.</param>
 /// <returns>The wedge product of two vectors.</returns>
 public double multiplyWedge(VectorD another)
 {
     return this.X * another.Y - this.Y * another.X;
 }
示例#14
0
        // ---------------------------------
        // ---------- multiplication -------
        // ---------------------------------

        /// <summary>
        /// Returns the scalar product of two vectors.
        /// 
        /// The scalar product of vectors A and B is equal to the value |A|*|B|*sin(phi),
        /// where phi is the angle between A to B.
        /// </summary>
        /// <param name="another">Another vector to find the scalar product to find the scalar product between the current vector and the specified.</param>
        /// <returns>The scalar product of two vectors.</returns>
        public double multiplyScalar(VectorD another)
        {
            return this.X * another.X + this.Y * another.Y;
        }