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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:47:28+00:00 2026-05-23T23:47:28+00:00

Hello everyone, I am implementing a cubic bezier curve for my project and I

  • 0

Hello everyone,
I am implementing a cubic bezier curve for my project and I have to store the calculated control points in a file. I have to use the output file in gnuplot to view the curve. Following one of the posts here, I understood how to implement but I am confused on how to get my output to a file. When I tried it just writes the values of the last point it calculates. Since there is a loop so I should have the values being written in the file as soon as it generates it. Here is the code below:

import math

points = [(0,0), (5,0), (5,5), (10,5)]

n = 20

for i in range(n) :

        u = i / float(n)

        x = math.pow(1-u,3) * points[0][0] + 3 * u * math.pow(1-u,2) * points[1][0] \
        + 3 * (1-u) * math.pow(u,2) * points[2][0] + math.pow(u,3) * points[3][0]
        y = math.pow(1-u,3) * points[0][1] + 3 * u * math.pow(1-u,2) * points[1][1] \
        + 3 * (1-u) * math.pow(u,2) * points[2][1] + math.pow(u,3) * points[3][1]

        print "(x,y)=", (x, y)     

Could someone help me please. Thank you.

  • 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-05-23T23:47:29+00:00Added an answer on May 23, 2026 at 11:47 pm

    f = open('somefile.dat', 'w+') opens (and creates) a file. With f.write() you can write a string to the file. In you case, you have to substitute the print call with the writecall:

    import math
    points = [(0,0), (5,0), (5,5), (10,5)]
    n = 20
    f = open('somefile.dat', 'w+')
    
    for i in range(n) :
    
        u = i / float(n)
    
        x = math.pow(1-u,3) * points[0][0] + 3 * u * math.pow(1-u,2) * points[1][0] \
        + 3 * (1-u) * math.pow(u,2) * points[2][0] + math.pow(u,3) * points[3][0]
        y = math.pow(1-u,3) * points[0][1] + 3 * u * math.pow(1-u,2) * points[1][1] \
        + 3 * (1-u) * math.pow(u,2) * points[2][1] + math.pow(u,3) * points[3][1]
    
        f.write("(x,y)=(%f, %f)"% (x, y))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everyone i currently have this: import feedparser d = feedparser.parse('http://store.steampowered.com/feeds/news.xml') for i in
Hello everyone I have converted a project in C# to F# that paints the
Hello everyone I use Excel 2010 with VB Ok so I have an issue
Hello everyone, I am making a VC++ 2008 project in pure Win32 API which
Hello everyone i am working on a project which requires me to export some
Hello everyone, I have some confusion regarding some Win32 API data types and macros
Hello everyone I have a problem. I want to do a GridView with a
Hello everyone I'm currently implementing a simple programming language for learning experience but I'm
hello everyone im trying to create this tweak that copies a file from one
Hello everyone. I'm using Silverlight webbrowser control, and I'm having some problems with that.

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.