A Flash Developer Resource Site

1. ## Focus of Parabola

Hi,
I need help finding the focus of this parabola:
y=x^2*.0334-x*8.35+525
The the focus's x is at 125, but I'm not sure how to find the y.

Thanks
Neal

2. plug in the x value for the focus into your function and see what y value it equals

3. you can't do that

you need to put the equation in the form of (x-b)^2 = 4a(y-c) and then the focal length is a - so the focal point will be a above the vertex

i'm in a rush now but will change the equation for you later

4. y=x^2*.0334-x*8.35+525
10000y = 334x^2 - 83500x + 5250000
10000/334y = x^2 - 250x + 5250000/334
10000/334y - 5250000/334 = x^2 - 250x
10000/334y - 5250000/334 + 15625 = x^2 - 250x + 15625
10000/334y - 5250000/334 + 15625 = (x-125)^2

if the left hand side was in the form 4a(y-c) then a would be:
2500/334

find the vertex of the parabola and move 2500/334 upwards to find the focus

5. I would solve this problem through the view of "Slope".

For a parabola y=a*x^2+b*x+c;
The tangential slope along the parabola line is a function of x.
slope=2*a*x+b; //the slope of reflection mirror

At the vertex point, the slope is 0.
For some point along the line, when light enters the parabola vertically , light is reflects to horizonal direction. The slopes of left point is -1 and right point is 1. That Y is the focus y;

So, to get the vertex X, the slope is 0. We solve the equation: 0=2*a*x+b;
We get x=-b/(2*a); // 125;

For the left refelction point, the slope is -1. We solve the equation -1=2*a*x+b;
We get x=(-1-b)/(2*a); //x1=110.02994011976
The focus Y=a*x*x+b*x+c; // we get 10.6100299401198;

If we want to test the right reflection point, then the slope is 1. We solve the equation: 1=2*a*x+b;
We get x=(1-b)/(2*a); //x2=139.97005988024;
The focus Y=a*x*x+b*x+c; // we get 10.6100299401197;

The focus Y calculated from left relection point and right reflection point are the same.
And the result is the same as calculated by a_slosh's method.

6. Many thanks to everyone who replied. I'm trying to get circles to realistically bounce off of a parabola. That involves getting tangent lines, so ericlin's response was relevant to that also. I'll post again later with the result. Now that I've got that down, another question arose. The circles have known radii. Is there an easy way to find a relation between the y value of the circles and the given angle? (see attached file for an example) The angle is a radius to the circle and is perpindicular to a tangent line shared by the circle and the parabola. Knowing that would make it much simpler to detect collision between the two, since you just have to test two points. I guess it's a little far out there, but hopefully someone around here will nudge me in the right direction.

Thanks
Neal

7. very clever idea eric

nialsh i'll look into it and let you know, there is definitely a relationship

8. I think I'm just re-iterating what Eric said, but...

It is easier to get an angle using the _x value of the circle.

y = x^2*.0334-x*8.35+525;

the slope is given by

slope = 2 * .0334 * x - 8.35;

And the angle (in degrees) is given by

angle = Math.atan2(slope) * 180/Math.PI;

For a given y value, there are going to be 2 x values (due to the parabola going back up - i.e. two solutions to the quadratic formula).

9. Okay, it's been a while since I posted last, but I've been trying to get the right gelatinous effect and working on some other stuff.

Here's an SWF of the tangent formula at work:
http://www.geocities.com/nialsh/ParabolaTangent.swf
The original "spheres":
http://www.geocities.com/nialsh/LavaLamp.swf
"Spheres" limited by parabola:
http://www.geocities.com/nialsh/LavaLamp2.swf

I'm pretty pleased with the result, but I still need a better means of hit testing them than the midpoint. Each individual blob is actually pushed away from the wall based on its distance beyond the boundary (velocity) and a parabola tangent gotten from its y value (angle).

Let me know what you think.

Neal

10. I decided to mess around with more collision testing today and I've gotten a solution that I'm pretty pleased with. Check out the attached diagram for reference. I made a horizontal line through the center of the circle. Where it intersects the left side of the parabola, I drew a tangent line and then drew line L perpindicular to that. Then I found angle a between line L and the horizontal line and used that same angle to draw a radius on the circle. Point P, where that radius intersects the circle, is very close to the first point that would touch the parabola if they close enough together, so I used P for collison testing on the left side. I made another point on the same horizontal plane as P on the right side of the circle to test the right side of the parabola.

Anyway, the whole thing yielded a pretty good result. It's still a little sketchy, but it looks a lot better than before.

Neal

I tried to solve the collision by Math, but it involves cubic equation. I hate it.

Since Flash animation is frame based, strict accuracy is not necessary.

It seems that the inaccuracy is noted only when the ball is near the vetex.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap