need help constructing random parabolas
Displaying 1-2 of 2 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Technetium

X1, y1, x2, and y2 are defined fairly randomly (there are constraints, and both will always be within the 640x480 screen, but that shouldn't matter much).

x3 and y3 are determined automatically based on the other two coordinates. x3 is the halfway point between the other two, and y3 is whichever is lower - 20 pixels, making it at or near the minimum between the two other points. (it will look the other way around since Verge counts horizontal pixels from top to bottom, though).

From this, I need to calculate a, b, and c. The problem is that the old methods of substitution from highschool days do not work here, because I don't actually know what any of the coordinates are. The engine will know at run-time, but I don't. I tried leaving them as variables, but I was unable to cancel things out. This is as far as I got:


y1 = a*x1^2 + b*x1 + c
y2 = a*x2^2 + b*x2 + c
y3 = a*x3^2 + b*x3 + c

c = y1 - (a*x1^2 + b*x1)

y2 = a*x2^2 + b*x2 + y1 - (a*x1^2 + x1*b)
a*x2^2 = b*x2+y1 - (a*x1^2 - x1*b) - y2
a = (b*x2 + y1 - (a*x1^2 - x1*b) - y2) / x2^2


I defined c first because it was the easiest to define. However, you can see that I ended up getting stuck with a still defined in terms of a. If I tried then to define b using equation 3, I would also end up with b in part of the definition.

I need at least one point defined only in terms of {X1,Y1}...{X3,Y3}. Then I need the second point to be defined only in terms of those coordinates plus the previously defined point. Then the final point must be defined in terms of any other than itself. I just don't know how to get there.

Posted on 2006-01-09 12:27:53

CrazyAznGamer

I'm just wondering why you want to construct random parabolas. But that doesn't matter right now.
x=(-b +- sqrt(b^2 - 4ac))/2a ??

Kiddin' kiddin. Anyways, try:

a = -((x1 * (y2 - y3) - x2 * (y1 - y3) + x3 * (y1 - y2)) / ((x1 * x1 - x1 * (x2 + x3) + x2 * x3) * (x2 - x3))

b = ((x1 * x1) * (y2 - y3) - (x2 * x2) * (y1 - y3) + (x3 * x3) * (y1 - y2)) / (((x1 * x1) - x1 * (x2 + x3) + x2 * x3) * (x2 - x3))

Sorry that it can't be pasted directly into your code and work, though. The Order of Operations as directed by Verge says you need some more parenthesis in there.

I'm pretty sure my calculations are accurate.

Posted on 2006-02-08 20:49:00


Displaying 1-2 of 2 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.