Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9016599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:02:12+00:00 2026-06-16T04:02:12+00:00

I have several points, and I try to draw Bezier curve using code below

  • 0

I have several points, and I try to draw Bezier curve using code below

 PathFigure pf = new PathFigure(points.From, ps, false); //ps - list of Bezier segments
    PathFigureCollection pfc = new PathFigureCollection();
    pfc.Add(pf);
    var pge = new PathGeometry();
    pge.Figures = pfc;
    Path p = new Path();
    p.Data = pge;
    p.Stroke = new SolidColorBrush(Color.FromRgb(244, 111, 011));

My Bezier segments look like this

  • 1,2,3 points – first segment
  • 3,4,5 points – second
  • 5,6,7.. ..

But I got this strange curve (here is 3 big (Nodes) and 7 small ellipse (is my points)):

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:02:14+00:00Added an answer on June 16, 2026 at 4:02 am

    The line you’re getting is the union of three distinct Bezier curves – one for each group of three points. (One for each “Bezier segment”?)

    If you want a single smooth curve, you need to pass your 9 (or more) points as a single collection of points (single “Bezier segment”?), not as groups of three points.

    Edit: Apparently BezierSegment only supports three points, so no wonder this doesn’t work. Even ‘PolyBezierSegment’ just gives a collection of Bezier segments rather than a single smooth Bezier…

    So since WPF doesn’t give you anything useful, I knocked something together using the maths here. It’s a numeric solution, but it seems to be pretty performant even with enough points to look nice and smooth:

    PolyLineSegment GetBezierApproximation(Point[] controlPoints, int outputSegmentCount)
    {
        Point[] points = new Point[outputSegmentCount + 1];
        for (int i = 0; i <= outputSegmentCount; i++)
        {
            double t = (double)i / outputSegmentCount;
            points[i] = GetBezierPoint(t, controlPoints, 0, controlPoints.Length);
        }
        return new PolyLineSegment(points, true);
    }
    
    Point GetBezierPoint(double t, Point[] controlPoints, int index, int count)
    {
        if (count == 1)
            return controlPoints[index];
        var P0 = GetBezierPoint(t, controlPoints, index, count - 1);
        var P1 = GetBezierPoint(t, controlPoints, index + 1, count - 1);
        return new Point((1 - t) * P0.X + t * P1.X, (1 - t) * P0.Y + t * P1.Y);
    }
    

    Using this,

    private void Grid_Loaded(object sender, RoutedEventArgs e)
    {
        Point[] points = new[] { 
                new Point(0, 200),
                new Point(0, 0),
                new Point(300, 0),
                new Point(350, 200),
                new Point(400, 0)
            };
        var b = GetBezierApproximation(points, 256);
        PathFigure pf = new PathFigure(b.Points[0], new[] { b }, false);
        PathFigureCollection pfc = new PathFigureCollection();
        pfc.Add(pf);
        var pge = new PathGeometry();
        pge.Figures = pfc;
        Path p = new Path();
        p.Data = pge;
        p.Stroke = new SolidColorBrush(Color.FromRgb(255, 0, 0));
        ((Grid)sender).Children.Add(p);
    }
    

    gives

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several methods that I need to wrap in new methods in basically
I have a folder called code/ which has several .cpp files, that all need
I have several links that points to a single AJAX url. I can load
I have several controllers in my new app. One is called admin. For some
I have several objects in my app that can become nil at some point
There have been several questions posted to SO about floating-point representation. For example, the
I have several xml files with different node structure. I want to extract xml
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
I have several Delphi programs that maintain connections to a database (some Oracle, some
I have several different numbers in a group that range in sizes and would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.