Click to See Complete Forum and Search --> : Friends of ED book on math

04-19-2002, 06:00 PM
Has anyone bought the Friends of ED book Flash and Math(i forgot the exact title). I saw it today in a bookstore and it looked interesting. Any opinions?

04-22-2002, 05:16 PM
i heard it's really good. not only do you learn the examples in the book but you also get the knoledge for using this stuff in your own project. it's the next book i'm buying. if you want to know how it is email me and when i get it i tell you. peace

04-22-2002, 05:18 PM
the book has it's own site,

04-22-2002, 06:42 PM
I went ahead and bought it. It is good. I have enjoyed playing around with it so far.

04-23-2002, 09:12 AM
i thought it was pretty cool too. but then again, i'm biased :D

04-23-2002, 07:28 PM
I bought it, because I need more maths for my flash and I wasn't awake enough at school. Its great - at the moment I'm working my way through David Hirmes work and I've learnt loads. I make his examples and then start changing them - today I was trying to work out a way to get a 1 to a 100 value from a Math.sin(i*(Math.PI/180)) starting point, went round the houses, phoned friends, then discovered two examples down the line that he's done it already, and it was right there in the book!! (but my way worked too - his is just more elegant!

The best of my flash books.

05-11-2002, 03:54 PM
I'd buy it but the American to Canadian conversions are too high - it would cost me well over $70.

05-11-2002, 03:56 PM
By the way Bit, your methods of creating elasticity, gravity are far too complex. There are easier methods.

05-11-2002, 04:32 PM
they also have some good examples / FLAs on the site ... some of they are pretty amazing as well !!

05-11-2002, 04:59 PM
Originally posted by Gloomycus
By the way Bit, your methods of creating elasticity, gravity are far too complex. There are easier methods.

please share.

05-12-2002, 08:38 PM
distSQ = dx*dx+dy*dy;
force = grav*b[j].m*b[k].m/distSQ;
total = Math.abs(dy)+Math.abs(dx)
ddx = (force*dx)/total;
ddy = (force*dy)/total;

Bit, my gravity routine is based on yours, so the variables might look familiar. I avoided trig by just splitting the total force proportionately between the x and y axis. It's correct, but I don't know that it is better, since Math.abs isn't necessarily quicker than trig, but it is different. I'm curious about the much less complex method for elasticity and gravity that Gloomycus has. :)

05-15-2002, 03:28 PM
i'm still waiting.

"my" method for gravity:


i honestly want to see something less complex than that. :)



i don't see how you could get a spring with less than that. of course you could COMBINE several of the steps and get something like:


but that's the same thing in shorthand.

05-15-2002, 03:43 PM
ironmallet, i did a test with your method and it does not give the same values as using trig. it's about .74 what the actual values would be. maybe close enough for flash though :)

05-16-2002, 04:49 AM
be warned-- this post is 100% bunk, I thought it made some sense at the time, read it if you slow down to look at car wrecks

It's different by a constant, so it's proportionally correct. You just have to change the 'gravitational constant', G.
I'll call the trig G, 'G2'
my supposition is that G=k*G2, where k is always the same

two examples:
ball 1 mass = 50kg, position=1m,3m (over and down)
ball 2 mass = 100kg,position=3m,4m

METHOD 1 (similar triangles)
so dist=sqrt(5), so distsq=5

force = G*(50*100)/5 = G*1000

total = 3

forcex = force*dx/total = g*1000*2/3 = 666G
forcey = force*dx/total = g*1000*1/3 = 333G

METHOD 2 (trig)
dist = sqrt(5), so distsq=5

force = G2*(50*100)/5 = G2*1000

angle (in radians) = atan(-1/2) = -.4636
c=cos(angle)= .8944
s=sin(angle)= .4472


so it appears that G=.75*G2, so k=.75

For the next i'll use 100 for both of the masses, and eliminate the units.
position ball 1 (67,89)
position ball 2 (115,-30)
dx=48, dy=-119
so distsq=16465


this time I got .77 for k, but that's rounding error.

anyway the point is that as long as the two forces change by the same factor, and that factor is the same for all angles, and is unaffected by distance, it's just a matter of tweaking the gravitational constant
[Edited by ironmallet on 05-19-2002 at 12:11 AM]

05-16-2002, 05:43 AM
you know what, i can't think of any hard reasons why my way should work.

my method is basically claiming that


which just isn't so

weird, it makes sense-sortof

05-16-2002, 12:24 PM
okay, sorry for blowing up this thread and all, but I figured out for sure that my method does not work!

In this example, the stationary particle figures out the forces using trig, the mouse following particle figures out the forces using the similar triangles method (which I still need to think through why it doesn't work). G is calculated and you can watch it change from .708 (sin 45) to up to 1. Not exactly a constant :)


Thanks for calling my attention to this bit, actually the first time I used this method was in 11th grade in C, on an apple ][. I've never noticed the error before, it's subtle.

05-18-2002, 04:23 PM
Originally posted by ironmallet
distSQ = dx*dx+dy*dy;
force = grav*b[j].m*b[k].m/distSQ;
total = Math.abs(dy)+Math.abs(dx)
ddx = (force*dx)/total;
ddy = (force*dy)/total;

This code is very wrong. The variable "total" makes no sense. If you want your code to work "total" should hold the distance between the two objects.

distance_squared = delta_x * delta_x + delta_y * delta_y;
distance = Math.sqrt (distance_squared);

force_gravity = G * mass1 * mass2 / distance_squared;

force_x = force_gravity * delta_x / distance;
force_y = force_gravity * delta_y / distance;

In the calculation of "force_x" and "force_y" you calculate the sine and cosine of the angle between the objects by dividing "delta_x" and "delta_y" by "distance." No need for a trigonometric function.

05-18-2002, 11:59 PM
Uh, yeah.

yes, thank you.

That's the way to avoid the trig function. The main problem with the 'total' ly wrong way I was doing it is, it looked like it worked... thanks bit and ahab.

It's so painfully obvious now that in a 3 4 5 triangle

3/5 not 3/7 of the force goes one way
4/5 not 4/7 of the force goes the other


ahab, btw, your site is sweet-- the 'batting demo' is sick.
[Edited by ironmallet on 05-19-2002 at 12:06 AM]

Ed Mack
06-01-2002, 06:23 PM
I think

mc._y += (vy++);

Is a lot simpler than:


So there!

06-01-2002, 11:13 PM
as i said in the same post, you can combine several steps, but that doesn't make the formula simpler, merely makes the code less understandable and less maintainable. so there! :)

Ed Mack
06-02-2002, 06:17 AM
More complex? As if. I saved the usage of another variable, and its a simple line. How about we have a vote?

06-02-2002, 09:07 AM
i didn't say "more complex"
i stand by my last post.

Ed Mack
06-04-2002, 07:27 AM
Ok, "less understandable" hehe

I just don't see how it is less understandable? This way, you don't have to remember what 3 different variables are for.

06-04-2002, 07:41 AM
additional variables, if well named, make code more understandable, not less. vy++ just says you are incrementing a variable vy. velocityY+=gravity says it all. short, compact code isn't necessarily better. it can sometimes be more efficient, but hell to maintain. i'm being a bit of a hypocrite here, since my personal source code is often pretty messy and breaks all kinds of rules for "proper programming style". but when i'm doing a tutorial or book, or code that someone else will need to use, i try to be a little more PC (programatically correct) :)

Ed Mack
06-04-2002, 12:06 PM
But they clutter everything up whilst in the debug process and make life harder sometimes.

06-04-2002, 05:28 PM
It seems to me that keeping a gravity variable can only make the code more flexible: While authoring it enables one to change the gravitational force for many parts of a system quickly and easily. Isn't this the point of not hard coding everything?
You may want to include a slider to control gravity at run time.
Overall I think it's simpler and more flexible.

06-04-2002, 07:26 PM
damn variables! should just get rid of 'em once and for all!

06-09-2002, 07:24 AM
Would the book be interesting for someone with a great knowledge of math as well? Or is it merely as an inspiration and "help" for those who have forgotten a lot of math since school?

Ed Mack
06-09-2002, 07:35 AM
I suppose a proper math book would be more for sombody in that position, ie. one that's going over more advanced topics, but not flash.