This content has been marked as final.
Show 7 replies

1. Re: A little math problem
Some1Won Sep 4, 2007 10:44 AM (in response to Pop_Clingwrap)Hello,
For a shape like half a ‘U’, you could try using a function for a parabola (can also look it up in google to see what the shape is like):
y = x^2
Or maybe you could also try a cubic (look it up in google to see what the curve looks like):
y = x^3
You can also stretch and compress these curves by multiplying constants:
y = 2(x^2) yields a steeper curve (twice as steep as y=x^2), while y = 1/2(x^2) yields a more gradual curve (half as steep as y=x^2)
(In both of the above functions, you’d probably only want half of the curve, where 0<= x). 
2. Re: A little math problem
Pop_Clingwrap Sep 5, 2007 2:28 AM (in response to Some1Won)Cheers for these. Very handy to know.
After much messing about and picking of other peoples brains I have ended up with this formula:
a = steepness of curve (1 = straight diagonal, 100 = almost a right angle)
b = the maximum value you want to output
y = (x^a)/(b^a)*b
I don't know if this is a recognized formula or not but it works well in my case so might be useful to others.
If anyone can simplify this or knows a better approach please post it. I would be interested to hear more on the whole line/curve/function subject.
Cheers 
3. Re: A little math problem
Bob_Robertson Sep 5, 2007 6:51 AM (in response to Pop_Clingwrap)y = (x^a)/(b^a)*b is the same as y = (x^a)/(b^[a1]) , for one thing. Not a biggie, but it might simplify things some internally.
You might also try using what's called a piecewise function, which is defined as different equations, depending on its input. So, in your example, you'd want to define it as, say, x/10 for x between 0 and 50; (x10)/0.8 +10 for the second part, and (x50)*2+50 for the third part. It's not really elegant, but it's pretty intuitive, which is important for learning new ideas.
If precise accuracy's not important and you just want to get a curve going, an Excel spreadsheet is a quick and dirty way to get an equation. Type in your known x coordinates in one column, and the associated y coordinates in another column. Graph them, with the XY (Scatter) type. Then, rightclick on a data point, and click Add Trendline. Play around with that, and be sure to select 'show equation' and 'show Rsquared value' under options. The closer rsquared is to 1.0, the more perfect a match the displayed equation will be.
Finally, I've found sosmath.com to be a good introductory resource, and http://mathforum.org/library/ looks fairly promising, as well.
Sorry if that's a bit of a brain dump, but I hope it helps
Bob 
4. Re: A little math problem
Pop_Clingwrap Sep 5, 2007 7:45 AM (in response to Bob_Robertson)This is all good stuff. Thanks a lot.
I have only skimmed these links but they look really good. http://mathforum.org/library/ has a lot of stuff on fractals and cellular automata both of which I have tried to build in AS in the past (usually resulting in infinite loops and crashes :)).
Keep em coming if you have more. Number 5 needs input! :) 
5. Re: A little math problem
kglad Sep 5, 2007 8:05 AM (in response to Pop_Clingwrap)actually, the curve you want is an exponential curve and not a polynomial (that you're currently using):
y = b^(c*x+d)e, where b, c, d and e are constants that you can solve for your particular needs.
but if that polynomial works for you, keep using it because it's easier for flash to calculate the values of that simple polynomial than it is to calculate the values of an exponential function. 
6. Re: A little math problem
Pop_Clingwrap Sep 5, 2007 8:38 AM (in response to Pop_Clingwrap)the polynominal (new word for the day!) seems to do the job in this instance but I will definately have a play around with any other methods that get posted here. It's all good stuff to know and its a personal interest of mine (trying to make up for not paying attention in maths when I was at school) 
7. Re: A little math problem
kglad Sep 5, 2007 11:27 AM (in response to Pop_Clingwrap)yes, i'd have to say i've never used as much math outside of school as that used in flash.