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 8823983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:29:38+00:00 2026-06-14T06:29:38+00:00

Can someone smarter than me take a look at this. I’m trying to implement

  • 0

Can someone smarter than me take a look at this. I’m trying to implement a Bezier curve algorithm I found here in objective-c.

The output is way wrong. I think I converted the code correctly so either the original was wrong or was not ment to be used like this… If I use the built in NSBezierPath the curve looks great but I can’t use the built in NSBezierPath.

NSBezierPath example

NSBezierPath *bezierPath = [[NSBezierPath alloc] init];
[bezierPath setLineWidth:1.0f];
[bezierPath moveToPoint:NSMakePoint(x1, y1)];
[bezierPath curveToPoint:NSMakePoint(x4, y4) controlPoint1:NSMakePoint(x2, y2) controlPoint2:NSMakePoint(x3, y3)];

My code trying to draw a bezier curve

- (void)drawBezierFrom:(NSPoint)from to:(NSPoint)to controlA:(NSPoint)a controlB:(NSPoint)b color:(NSUInteger)color
{
    float qx, qy;
    float q1, q2, q3, q4;
    int plotx, ploty;
    float t = 0.0;
    
    while (t <= 1)
    {
        q1 = t*t*t*-1 + t*t*3 + t*-3 + 1;
        q2 = t*t*t*3 + t*t*-6 + t*3;
        q3 = t*t*t*-3 + t*t*3;
        q4 = t*t*t;
    
        qx = q1*from.x + q2*to.x * q3*a.x + q4*b.x;
        qy = q1*from.y + q2*to.y * q3*a.y + q4*b.y;
    
        plotx = round(qx);
        ploty = round(qy);

        [self drawPixelColor:color atX:plotx y:ploty];
    
        t = t + 0.003;
    }
}

Edit

See Bezier curve algorithm in objective-c needs a tweak for a completed functional Bezier Curve method.

  • 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-14T06:29:40+00:00Added an answer on June 14, 2026 at 6:29 am

    I used this Bezier function with my xy plotter and found a small error with the ‘to’.
    The to.x to.y and b.x b.y need to be switched so that the pen starts at from and ends at to.

    qx = q1*from.x + q2*a.x + q3*b.x + q4*to.x;
    qy = q1*from.y + q2*a.y + q3*b.y + q4*to.y;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone who is way smarter than I tell me what I'm doing wrong..
I'm hoping someone smarter then me can answer this question. By default can all
Can someone please tell me what this means: 07-04 09:54:38.048: I/DetailActivity(15496): Title that is
Can someone tell me how to modify this regex to allow periods in a
can someone tell me what seems to be the issue with this <?php $increment
Can someone please explain to me how this responsive approach works? This was done
Can someone help me to tweak this regex?? I have this regex for twitter
I've bumped up against this before and I need the help of someone smarter
I am trying to implement an algorithm that takes in two ints n and
Can someone show me how to include this javascript file into my wordpress plugin.

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.