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

  • Home
  • SEARCH
  • 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 9063135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:54:51+00:00 2026-06-16T15:54:51+00:00

I have a set of points which approximate a 2D curve. I would like

  • 0

I have a set of points which approximate a 2D curve. I would like to use Python with numpy and scipy to find a cubic Bézier path which approximately fits the points, where I specify the exact coordinates of two endpoints, and it returns the coordinates of the other two control points.

I initially thought scipy.interpolate.splprep() might do what I want, but it seems to force the curve to pass through each one of the data points (as I suppose you would want for interpolation). I’ll assume that I was on the wrong track with that.

My question is similar to this one: How can I fit a Bézier curve to a set of data?, except that they said they didn’t want to use numpy. My preference would be to find what I need already implemented somewhere in scipy or numpy. Otherwise, I plan to implement the algorithm linked from one of the answers to that question, using numpy: An algorithm for automatically fitting digitized curves (pdf.page 622).

Thank you for any suggestions!

Edit: I understand that a cubic Bézier curve is not guaranteed to pass through all the points; I want one which passes through two given endpoints, and which is as close as possible to the specified interior points.

  • 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-16T15:54:52+00:00Added an answer on June 16, 2026 at 3:54 pm

    Here is a piece of python code for fitting points:

    '''least square qbezier fit using penrose pseudoinverse
        >>> V=array
        >>> E,  W,  N,  S =  V((1,0)), V((-1,0)), V((0,1)), V((0,-1))
        >>> cw = 100
        >>> ch = 300
        >>> cpb = V((0, 0))
        >>> cpe = V((cw, 0))
        >>> xys=[cpb,cpb+ch*N+E*cw/8,cpe+ch*N+E*cw/8, cpe]            
        >>> 
        >>> ts = V(range(11), dtype='float')/10
        >>> M = bezierM (ts)
        >>> points = M*xys #produces the points on the bezier curve at t in ts
        >>> 
        >>> control_points=lsqfit(points, M)
        >>> linalg.norm(control_points-xys)<10e-5
        True
        >>> control_points.tolist()[1]
        [12.500000000000037, 300.00000000000017]
    
    '''
    from numpy import array, linalg, matrix
    from scipy.misc import comb as nOk
    Mtk = lambda n, t, k: t**(k)*(1-t)**(n-k)*nOk(n,k)
    bezierM = lambda ts: matrix([[Mtk(3,t,k) for k in range(4)] for t in ts])
    def lsqfit(points,M):
        M_ = linalg.pinv(M)
        return M_ * points
    

    Generally on bezier curves check out
    Animated bezier and
    bezierinfo

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

Sidebar

Related Questions

I have a set of points which are contained within the rectangle. I'd like
I have a set of points and i want to draw a curve which
I have set of points which lies on the image. These set of points
I have a set of data points in 3D space which apparently all fall
I'm doing this graphics project in which I have a set of points(in 3
I have a set of data points (which I can thin out) that I
I have a set of sequential points which makes a 2D shape and i
The problem here is to find set of all integer points which gives minimum
I have set break points on my attached properties SetXXX and GetXXX static methods.
I have a set of points that i want to turn into a closed

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.