Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Get The middle point of an ArcSegment in WPF

Tags:

c#

wpf

What is the best solution for getting the middle point of an ArcSegment in a path and label it in WPF?

enter image description here

like image 742
ARZ Avatar asked Oct 15 '11 16:10

ARZ


1 Answers

This should work:

        //the given arc (or any other segments)
        var arc = new ArcSegment(
            point: new Point(200, 100),
            size: new Size(100, 50),
            rotationAngle: 90,
            isLargeArc: true,
            sweepDirection: SweepDirection.Counterclockwise,
            isStroked: true);

        //compose one or more segments into a collection
        var pathcoll = new PathSegmentCollection();
        pathcoll.Add(arc);

        //create a figure based on the set of segments
        var figure = new PathFigure();
        figure.Segments = pathcoll;

        //compose a collection of figures
        var figcoll = new PathFigureCollection();
        figcoll.Add(figure);

        //create a path-geometry using the figures collection
        var geom = new PathGeometry(figcoll);

        double fraction = 0.5;  //the relative point of the curve
        Point pt;               //the absolute point of the curve
        Point tg;               //the tangent point of the curve
        geom.GetPointAtFractionLength(
            fraction,
            out pt,
            out tg);

Hope it helps.

Cheers

like image 172
Mario Vernari Avatar answered Oct 23 '22 13:10

Mario Vernari