Is it possible to work out equation of a curve from 3 points?

Started by
7 comments, last by Extrarius 19 years, 4 months ago
Hi, I've got 3 points that form a curve. eg. (x,y): 786432, 12 480000, 10 307200, 8 And I was wondering if its possible to work out the equation of the curve from these 3 points. I've done 2Unit Year 12 maths, so if you could give me an idea of what I should be looking at to solve this, so I would know where to read up on it Since I haven't really done much maths for 2 years now. Thanks,
Advertisement
You can draw many, many (infinite?) curves that will fit those points. Those three points could very well be part of a sin curve, a cosine curve, or perhaps a any other form of curve.

However, if you know what type the curve is supposed to be, it may be possible.
Hmmm... you can definitely find curves which go through all of these points, this might be somewhat helpful, although I can't say that I've read through it closely...

[the lagrange curves]
linky


CJM
well all I need is from 0 to infinity on both axises.

Basically I'm doing it so I know how big to draw the text onscreen.

eg at
640x480, font size is 8
800x600, font size is 10
1024x768, font size is 12

And I don't know what the resolution maybe, so I thought If I could just put in an equation to work it out for me every time, that would be good.

heres an idea of what the graph may look like.




Quote:Is it possible to work out equation of a curve from 3 points?


Yes, if you place constraints as to what the form of the equation must be and it has the appropriate number of degrees of freedom.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
I'm assuming that if you got only 3 points and absolutely no more bits of information, your curve should be as simple as possible. That is:
y = a*x^2 + b*x + c;
where:
A * z = y
where:

A =
-----------------
| x0^2 | x0 | 1 |
-----------------
| x1^2 | x1 | 1 |
-----------------
| x2^2 | x2 | 1 |
-----------------

z = (a,b,c)^T
y = (y0,y1,y2)^T

In other words, solve the equation (off-line, of course), so you'll get a, b and c.
Simple.
/def
I see thanks, btw that looks like a quadratic equation..am i wrong?
well, I plugged it in to Excel, fit a 2nd order polynomial:

x=width * height
font_size = -1.05321E-11*x*x + 1.98650E-05*x + 2.89142


note that this won't work at higher resolutions; the font size will start decreasing again.
If this is for finding the proper font size for resolution X, why not just come up with a simple equation such as
Font Size = (Vert Res + Horz Res) / 140
That comes up with 8 for 640*480, 10 for 800*600, 12.8 for 1024*768, and 20 for 1600*1200 which seems close enough to your values to work. Area of the screen isn't a good representation for the 'X' in your 'curve' since really the values you're looking for are closer to linear IMO.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement