This content has been marked as final.
Show 18 replies
-
1. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 5:58 AM (in response to groveman)Math.sqrt(number)
I don't know where you want the divisor to be
Math.sqrt(drag*area)
or
(Math.sqrt(drag*area)*speed)
e.g.
permissible = hookload*1.2/(Math.sqrt(drag*area)*speed) -
2. Re: ActionScript 2 help please!
groveman Aug 9, 2007 7:33 AM (in response to groveman)Thanks for info but the Math.sqrt division*speed must take place after drag*area is calculated! Any further suggestions appreciated -
3. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 7:39 AM (in response to groveman)Maybe I'm missing something obvious but I'm afraid I don't understand your requirements.
If you want the square root of drag*area
then its
Math.sqrt(drag*area)
division takes precedence over multiplication...
so you put brackets around anything that should be evaluated first that conflicts with that...
-
4. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 7:44 AM (in response to groveman)This might help:
var test = 3*2/Math.sqrt(4*4)*3
//is evaluated like this:
//Math.sqrt is first...
// 3*2/4*3
// 3*0.5*3
// 1.5*3
//4.5
trace(test) -
5. Re: ActionScript 2 help please!
Newsgroup_User Aug 9, 2007 7:59 AM (in response to groveman)>> division takes precedence over multiplication...
Actually, they have the same order.
Example: trace( 4 * 4 / 4);
You get 4, not 1...
--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/
-
6. Re: ActionScript 2 help please!
Newsgroup_User Aug 9, 2007 8:00 AM (in response to groveman)>>You get 4, not 1...
You get 4, not 16... is what I meant to say.
--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/
-
7. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 8:24 AM (in response to Newsgroup_User)I stand corrected - I understand what you mean. Its been a while since I studied math.
Although your example gives 4 either way (4*(4/4) is 4*1... is 4). & (4*4) /4..... 16/4 is also 4.
What I meant to say was that
4*4/4*4 is different to 4*4/(4*4) and won't be interpreted that way.
-
8. Re: ActionScript 2 help please!
groveman Aug 9, 2007 8:28 AM (in response to groveman)Sorry to be a pain but the syntax still gives the wrong answer!
For hookload the input value is 16*1.2 = 19.2 (1.2 adds a safety factor)
For area the input is 20
For drag the input is 1.3
For speed the input is 9
Giving: 16 x 1.2 =19.2 divided by drag 1.3 x area 20 = 26 = 0.738 with sqrt of 0.859 x speed 9 =7.731
Hope this helps understanding in what i'm trying to solve! -
9. ActionScript 2 help please!
cicnats Aug 9, 2007 8:31 AM (in response to Newsgroup_User)erm, not to be splitting hairs, but doesn't 4*4/4 retun 4 in any order you calculate it?
and
4*4/(4*4) = 1
4*(4/(4*4)) = 1
(4*4)/(4*4) = 1
em.. i think it just.. em... doesn't prove much...
edit: blimey... 4*4/4*4 is 16.... that means... uh... math... -
10. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 8:38 AM (in response to groveman)permissible = Math.sqrt(hookload*1.2/(drag*area))*speed -
11. Re: ActionScript 2 help please!
jmwoodcock Aug 9, 2007 8:41 AM (in response to groveman)quote:
Originally posted by: groveman
permissible = hookload*1.2/(drag*area)*speed)
The reason this gives a syntax error is because you don't have the correct number of parenthesis.
permissible = (hookload*1.2)/((drag*area)*speed);
Notice the two opening parenthesis before drag. I also added parenthesis around the hookload equation for good measure.
Hope this helps. When doing these type of equations you have to be very careful about grouping and your syntax. When you have three opening parenthesis, for example, you must have 3 closing.
John -
12. Re: ActionScript 2 help please!
cicnats Aug 9, 2007 8:42 AM (in response to groveman)erm.. ok.. i get it... i think..
4*4/4*4 is different from 4*4/(4*4) .. . but I'm not sure it that shows precedence of division.. just lack of precedence of multiplication... i think... -
13. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 8:43 AM (in response to groveman)@cicnats:
trace(4*4/(4*4)) //1
trace(4*4/4*4) //16 -
14. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 8:44 AM (in response to groveman)@cicnats... yeah like I said.... I didn't express it properly. Sorry for adding to the confusion -
15. Re: ActionScript 2 help please!
cicnats Aug 9, 2007 8:55 AM (in response to groveman)I think we can agree that the lesson learned is to use parenthesis whenever in doubt :)
but to push the case one last time.. I think you may be right.. since it seems flash does implement precedence of multiplication over addition.. it probably precedes division over multiplication, because I think I remember from math that it should be that way..
oh.. and lesson 2 to read code more carefully so we don't go off topic (i mean, since the problem was a syntax error due to a typo) :) -
16. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 8:55 AM (in response to groveman)@groveman: in case you missed it, I posted what I think you were looking for a few posts up....
permissible = Math.sqrt(hookload*1.2/(drag*area))*speed -
17. Re: ActionScript 2 help please!
Greg Dove Aug 9, 2007 9:02 AM (in response to cicnats)@cicnats: agreed. I tend to over use parentheses to help me interpret the code when I look at it next time (if that makes sense...sometimes it can be difficult when there are lots).
The idea of multiplication over addition as a math rule is something I had 'embedded' as some vague recollection so I wasn't 100% sure. I did see the typo too but focused on the other stuff because it seemed like the real issue was trying to get the right calculation in the first place. -
18. Re: ActionScript 2 help please!
groveman Aug 9, 2007 10:40 AM (in response to Greg Dove)That fixed it! Many thanks for your kind assistance