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

Page 1 of 1

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

### #1 PixelBit

Reputation: 6
• Posts: 233
• Joined: 17-July 11

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

Posted 18 September 2012 - 12:48 AM

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

Is This A Good Question/Topic? 0

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

### #2 cfoley

• Cabbage

Reputation: 2335
• Posts: 4,882
• Joined: 11-December 07

## 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:

```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 TheGDeveloper

Reputation: 10
• Posts: 93
• Joined: 22-September 09

## 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

### #4 IceHot

Reputation: 0
• Posts: 220
• Joined: 28-August 12

## 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

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

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}