473,382 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Bezier curve

Hi all

I want to draw a line as if it were being drawn in real-time by a person.
To save lots of data I think that storing 4 points in memory and drawing a
bezier curve would be efficient. What I need to know is, how can I
determine each of the required pixel positions so that I may loop through
them and draw them onto a canvas over a timespan of (for example) 1 second?
Thankyou!
Pete
Nov 11 '07 #1
2 7104
http://www.moshplant.com/direct-or/bezier/ will give you the math, given the
four points. To draw the curve in real time, start at the point with the
smallest x coordinate, and calculate y for each pixel, as you increment the
x coordinate by one. Stop when you reach the point with the largest x
coordinate.

A Google search on "Bezier curve" will give you many useful links.

"Peter Morris" <su*****@NOdroopySPAMeyes.comwrote in message
news:uK**************@TK2MSFTNGP03.phx.gbl...
Hi all

I want to draw a line as if it were being drawn in real-time by a person.
To save lots of data I think that storing 4 points in memory and drawing a
bezier curve would be efficient. What I need to know is, how can I
determine each of the required pixel positions so that I may loop through
them and draw them onto a canvas over a timespan of (for example) 1
second?
Thankyou!
Pete

Nov 11 '07 #2
That site had just what I needed, thanks :-)

private Point GetBezierPoint(float t, Point p0, Point p1, Point p2, Point
p3)

{

float cx = 3 * (p1.X - p0.X);

float bx = 3 * (p2.X - p1.X) - cx;

float ax = p3.X - p0.X - cx - bx;

float cy = 3 * (p1.Y - p0.Y);

float by = 3 * (p2.Y - p1.Y) - cy;

float ay = p3.Y - p0.Y - cy - by;

float tCubed = t * t * t;

float tSquared = t * t;

float resultX = (ax * tCubed) + (bx * tSquared) + (cx * t) + p0.X;

float resultY = (ay * tCubed) + (by * tSquared) + (cy * t) + p0.Y;

return new Point((int)resultX, (int)resultY);

}

Pete
Nov 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vinodh Kumar | last post by:
Number One: ========= I know its a 100% offline post.But seeing the diversity of the domain from which people are participating, I would like to post this question here.Pardon me.At the least, u...
5
by: reagan | last post by:
I am trying to get a program(in visual C++) to draw a sine curve (from 0 to 2pi). It takes 8 lines to draw the complete curve. However, the user can choose to use up to 100 lines to make the curve...
2
by: MLH | last post by:
This question, I apologize, is more of a math question than it is an Access question - I'm almost certain. The bell curve is another name for the normal distribution, which is a common type of...
4
by: nmukh1 | last post by:
Hey guys, I'm trying to optimize a program that measures the length of a curve. Suppose I define a function f and I have two bounds and am trying to find the arc length. The familiar calculus...
2
by: Dennis Myrén | last post by:
Hi. Sorry if this post might be a little off the topic, but just in case anyone knows... Given a size, a position, a start angle and a sweep angle, i want to draw a bezier curve. I will...
8
by: scorpion53061 | last post by:
Hi, I am a vb.net guy......(I know boo hiss LOL) I was thinking of learning C# as well. Can I expect a hard road of it as far as a learning curve? As as side note, what made you choose...
9
by: Warren Francis | last post by:
I'm fairly new to Python (2-3 months) and I'm trying to figure out a simple way to implement Bezier curves... So far I've tried the following: http://runten.tripod.com/NURBS/ ....which won't...
4
by: babyinc | last post by:
Please help me. I am totally beginner of C++ and my tutor give us these huge program to solve within 20 days. As a MSc student I am really gonna cry. Please anyone can help me. sumon1in1@yahoo.com ...
0
by: sa6113 | last post by:
Hello there, I have a problem on curve fitting , would you please help me ?! I want to to develop a application that reads a text file with 2 columns of floating point data (as x and y) and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.