I don't know where I should have posted this, so I hope this is right.

I'm making a Javascript library for learning purposes, and for some of the animation functions I'm going to need the equation of a specific quadratic curve based on three inputs from, to and q.

Anyway I want to construct a quadratic equation (one that curves upwards not down) goes through three points, and I need it to be a method that I can write up into code (I will be using Javascript). I haven't gotten very far, but this is what I have planned out so far...

basically two numbers are input (from and to), d= to-from

a = (0,0)

b = (d,0)

c = (p,q) p=d/2 q=Any input number, let's say 5

Then i need to get it into the form y=ax^2+bx+c but I'm not sure how to do this in a way that I can program it.

Cheers,

~Jamal

## 3 Replies - 3977 Views - Last Post: 12 January 2013 - 03:51 PM

### #1

# How to make a quadratic curve equation given 3 coords?

Posted 18 September 2012 - 12:48 AM

##
**Replies To:** How to make a quadratic curve equation given 3 coords?

### #2

## Re: How to make a quadratic curve equation given 3 coords?

Posted 18 September 2012 - 02:37 AM

In other words, the roots are x=0 and x=d, and the top of the curve is at y=q.

Think about how you solve an equation to get the roots, you put it in the form:

You should now be able to work out a formula for an equation that passes through your required roots. To get it to pass through (d/2, q) you will need to multiply your equation by a constant. That should be fairly trivial to do.

Think about how you solve an equation to get the roots, you put it in the form:

0 = (x+a)(x+B)/>

You should now be able to work out a formula for an equation that passes through your required roots. To get it to pass through (d/2, q) you will need to multiply your equation by a constant. That should be fairly trivial to do.

### #3

## Re: How to make a quadratic curve equation given 3 coords?

Posted 12 November 2012 - 01:26 PM

You are trying to implement Bezier Curves with three points and you can use the well known De Casteljau's algorithm

http://en.wikipedia....u%27s_algorithm

here is the implementation in javascript

https://gist.github.com/1049745

http://en.wikipedia....u%27s_algorithm

here is the implementation in javascript

https://gist.github.com/1049745

### #4

## Re: How to make a quadratic curve equation given 3 coords?

Posted 12 January 2013 - 03:51 PM

I have a non-recursive, non-iterative way to do it. It isn't as nice as the recursive way, though. It involves simple matrix arithmetic.Dammit...the server isn't letting me upload!

EDIT: It became beautiful. Oh, and file-sharing servers FTW: http://www.freefileh...venthreepoints2

EDIT: It became beautiful. Oh, and file-sharing servers FTW: http://www.freefileh...venthreepoints2

This post has been edited by **IceHot**: 12 January 2013 - 05:11 PM

Page 1 of 1