Esempio n. 1
0
        /// <summary>
        /// Create and arc from three points.
        /// </summary>
        /// <param name="centre">The centre of the arc.</param>
        /// <param name="p1">The starting point</param>
        /// <param name="p2">The end point</param>
        public MarkGeometryArc(MarkGeometryPoint centre, MarkGeometryPoint p1, MarkGeometryPoint p2)
        {
            Radius      = GeometricArithmeticModule.ABSMeasure(centre, p1);
            StartAngle  = GeometricArithmeticModule.CalculateAngle(centre, p1);
            EndAngle    = GeometricArithmeticModule.CalculateAngle(centre, p2);
            CentrePoint = centre;

            StartPoint = p1;
            EndPoint   = p2;

            Update();
        }
Esempio n. 2
0
        /// <summary>
        /// see: http://www.lee-mac.com/bulgeconversion.html
        /// The curvature of a Polyline Arc segment is defined using a quantity known as bulge.
        /// This unit measures the deviation of the curve from the straight line (chord) joining the two vertices of the segment.
        /// It is defined as the ratio of the arc sagitta (versine) to half the length of
        /// the chord between the two vertices; this ratio is equal to the tangent of a
        /// quarter of the included arc angle between the two polyline vertices.
        /// </summary>
        /// <param name="startPoint"></param>
        /// <param name="endPoint"></param>
        /// <param name="bulge"></param>
        public MarkGeometryArc(MarkGeometryPoint startPoint, MarkGeometryPoint endPoint, double bulge)
        {
            var d  = GeometricArithmeticModule.ABSMeasure(startPoint, endPoint) / 2d;
            var r  = (d * ((Math.Pow(bulge, 2)) + 1)) / (2 * bulge);
            var th = GeometricArithmeticModule.CalculateAngle(startPoint, endPoint) + Math.Acos(d / r);

            Radius      = Math.Abs(r);
            CentrePoint = MarkGeometryPoint.FromPolar(startPoint, th, r);

            if (bulge < 0)
            {
                StartAngle = GeometricArithmeticModule.CalculateAngle(CentrePoint, endPoint);
                EndAngle   = GeometricArithmeticModule.CalculateAngle(CentrePoint, startPoint);
            }
            else
            {
                StartAngle = GeometricArithmeticModule.CalculateAngle(CentrePoint, startPoint);
                EndAngle   = GeometricArithmeticModule.CalculateAngle(CentrePoint, endPoint);
            }

            Update();
        }