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

#1 PixelBit  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • 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  Icon User is online

  • Cabbage
  • member icon

Reputation: 1937
  • View blog
  • Posts: 4,022
  • 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.
Was This Post Helpful? 1
  • +
  • -

#3 TheGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#4 IceHot  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 199
  • 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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1