Esempio n. 1
0
 /// <summary>
 /// 构造函数,通过一个浮点尺寸实例和一个原点坐标创建一个矩形实例。
 /// </summary>
 /// <param name="size">指定的浮点尺寸实例。</param>
 public ExRectangle(SizeF size) : base()
 {
     LeftTopVertex     = new ExPoint2D();
     LeftBottomVertex  = (0, -size.Height);
     RightTopVertex    = (size.Width, 0);
     RightBottomVertex = (size.Width, -size.Height);
 }
Esempio n. 2
0
 /// <summary>
 /// 构造函数,通过一个指定的左上角顶点和一个浮点尺寸实例创建当前的矩形实例。
 /// </summary>
 /// <param name="ltVertex">一个左上角顶点。</param>
 /// <param name="size">指定的浮点尺寸实例。</param>
 public ExRectangle(ExPoint2D ltVertex, SizeF size) : base()
 {
     LeftTopVertex     = ltVertex;
     LeftBottomVertex  = (0, ltVertex.YPosition + (-size.Height));
     RightTopVertex    = (ltVertex.XPosition + size.Width, ltVertex.YPosition);
     RightBottomVertex = (ltVertex.XPosition + size.Width, ltVertex.YPosition + (-size.Height));
 }
 /// <summary>
 /// 构造函数,创建一个指定半径和圆心位置的圆。
 /// </summary>
 /// <param name="center">圆心的坐标。</param>
 /// <param name="radius">指定的半径。</param>
 /// <exception cref="IllegalRadiusDefinitionException">当半径设定值小于或者等于0时,则将会抛出这个异常。</exception>
 public Circular(ExPoint2D center, double radius)
 {
     if (radius <= 0)
     {
         throw new IllegalRadiusDefinitionException();
     }
     else
     {
         _radius = radius;
         _center = center;
     }
 }
 /// <summary>
 /// 构造函数,定义一条穿过任意两个二维点的直线。
 /// </summary>
 /// <param name="point01">任意一个二维点。</param>
 /// <param name="point02">另外一个任意二维点。</param>
 /// <exception cref="UnknownDirectionLineException">当无法确定所定义的直线的斜率时,则会抛出这个异常。</exception>
 public StraightLine2D(ExPoint2D point01, ExPoint2D point02)
 {
     if (point01.Equals(point02))
     {
         throw new UnknownDirectionLineException();
     }
     else
     {
         _anyPoint01 = point01;
         _anyPoint02 = point02;
     }
 }
 protected ExPoint2D _anyPoint02; //直线上另外一个任意二维点。
 /// <summary>
 /// 构造函数,定义一条经过笛卡尔平面直角坐标系原点的直线。
 /// </summary>
 /// <param name="nonOriginPoint">在任意象限和轴上的非原点的任意二维点。</param>
 /// <exception cref="UnknownDirectionLineException">当无法确定所定义的直线的斜率时,则会抛出这个异常。</exception>
 public StraightLine2D(ExPoint2D nonOriginPoint)
 {
     if (new ExPoint2D().Equals(nonOriginPoint))
     {
         throw new UnknownDirectionLineException();
     }
     else
     {
         _anyPoint01 = new ExPoint2D();
         _anyPoint02 = nonOriginPoint;
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 构造函数,通过矩形的四个顶点来创建当前矩形实例。
        /// </summary>
        /// <param name="ltVertex">左上角顶点。</param>
        /// <param name="lbVertex">左下角顶点。</param>
        /// <param name="rtVertex">右上角顶点。</param>
        /// <param name="rbVertex">右下角顶点。</param>
        public ExRectangle(ExPoint2D ltVertex, ExPoint2D lbVertex, ExPoint2D rtVertex, ExPoint2D rbVertex) : base()
        {
            LeftTopVertex     = ltVertex;
            LeftBottomVertex  = lbVertex;
            RightTopVertex    = rtVertex;
            RightBottomVertex = rbVertex;
            (StraightLine2D L1, StraightLine2D L2)lines = GetDiagonals();
            bool distanceIsEqual    = lines.L1.GetDistanceWith() != lines.L2.GetDistanceWith();
            bool includeAngleIsZero = GetDiagonalIncludedAngle().Size == 0;

            if (distanceIsEqual || includeAngleIsZero)
            {
                throw new NonStandardGraphicalException();
            }
        }
 /// <summary>
 /// 将当前的图形围绕指定点旋转指定角度。
 /// </summary>
 /// <param name="axisPoint">二维点旋转的中心点。</param>
 /// <param name="angle">逆时针旋转的角度。</param>
 /// <returns>这个操作会返回一个通过逆时针旋转后获取到的新的图形实例。</returns>
 public abstract Shape2D Rotate(ExPoint2D axisPoint, Angle angle);
 /// <summary>
 /// 将整个图形进行坐标平移。
 /// </summary>
 /// <param name="offsetPoint">偏移量,即在横轴和纵轴上平移的长度。</param>
 public abstract void Translation(ExPoint2D offsetPoint);