/// <summary>
        /// Gets the horizontal plane length
        /// </summary>
        /// <param name="axisRange"></param>
        /// <param name="origin"></param>
        /// <returns></returns>
        public double GetPlaneLength(NRange1DD axisRange, double origin, int originPoint, bool xOrZ)
        {
            NVector3DD vecA = GetVectorFromPoint(0);
            NVector3DD vecB = GetVectorFromPoint(1);

            NVector3DD lengthVector = new NVector3DD();

            lengthVector.Subtract(ref vecB, ref vecA);
            double orgPlaneLength = lengthVector.GetLength();
            double sign;

            if (originPoint == 0 || originPoint == 2)
            {
                // left point
                if (xOrZ)
                {
                    sign = vecA.X < vecB.X ? 1 : -1;
                }
                else
                {
                    sign = vecA.Z < vecB.Z ? 1 : -1;
                }
            }
            else
            {
                // right point
                if (xOrZ)
                {
                    sign = vecB.X < vecA.X ? 1 : -1;
                }
                else
                {
                    sign = vecB.Z < vecA.Z ? 1 : -1;
                }
            }

            axisRange.Normalize();

            if (sign > 0)
            {
                if (origin + orgPlaneLength > axisRange.End)
                {
                    orgPlaneLength = axisRange.End - origin;
                }
            }
            else
            {
                if (origin - orgPlaneLength < axisRange.Begin)
                {
                    orgPlaneLength = origin - axisRange.Begin;
                }
            }

            return(orgPlaneLength * sign);
        }
        /// <summary>
        /// Synchronizes the points so that they are coplanar
        /// </summary>
        /// <param name="modifiedPointIndex"></param>
        public void SynchronizePoints(int modifiedPointIndex)
        {
            // then align points depending on which point is being dragged
            NVector3DD vecA = GetVectorFromPoint(0);
            NVector3DD vecB = GetVectorFromPoint(1);
            NVector3DD vecC = GetVectorFromPoint(2);
            NVector3DD vecD = GetVectorFromPoint(3);

            switch (modifiedPointIndex)
            {
            case 0:                     // left top
                // sync point 3 (left bottom)
            {
                NVector3DD vecCB = new NVector3DD();
                vecCB.Subtract(ref vecC, ref vecB);

                vecD.Add(ref vecA, ref vecCB);

                SetVectorToPoint(3, vecD);
            }
            break;

            case 1:                     // right top
            {
                // sync point 2 (right bottom)
                NVector3DD vecDA = new NVector3DD();
                vecDA.Subtract(ref vecD, ref vecA);

                vecC.Add(ref vecB, ref vecDA);

                SetVectorToPoint(2, vecC);
            }
            break;

            case 2:                     // right bottom
            {
                // sync point 1 (right top)
                NVector3DD vecAD = new NVector3DD();
                vecAD.Subtract(ref vecA, ref vecD);

                vecB.Add(ref vecC, ref vecAD);

                SetVectorToPoint(1, vecB);
            }
            break;

            case 3:                     // left bottom
            {
                // sync point 0 (left top)
                NVector3DD vecCB = new NVector3DD();
                vecCB.Subtract(ref vecB, ref vecC);

                vecA.Add(ref vecD, ref vecCB);

                SetVectorToPoint(0, vecA);
            }
            break;
            }

            // handle x / z locking
            if (m_LockX)
            {
                double x = GetVectorFromPoint(modifiedPointIndex).X;
                for (int i = 0; i < 4; i++)
                {
                    if (i != modifiedPointIndex)
                    {
                        SetXPointCoordinate(i, x);
                    }
                }
            }

            if (m_LockZ)
            {
                double z = GetVectorFromPoint(modifiedPointIndex).Z;

                for (int i = 0; i < 4; i++)
                {
                    if (i != modifiedPointIndex)
                    {
                        SetZPointCoordinate(i, z);
                    }
                }
            }
        }