dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: The Math Class?

  1. #1
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193

    The Math Class?

    I've been looking at the Math class a little bit as well as the Conversion Calculator on the Exchange which uses the round() method.

    I was hoping someone might reply here as to other uses of this class and maybe point to some examples, in particular the use of the trigonometry methods of the Math Class. I had done an "angle finder" in excel once which used trig and suppose one could do that in KoolMoves similar to the converter.

    Anyone?

  2. #2
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Guess I need to browse around the rest of flashkit. I just looked into the Math and Physics forum which may be of use to those interested in this topic. It may be a moot point considering the fact that I am writing to myself. I must be going crazy.

  3. #3
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    I'm not sure what you are looking for since the Math class is easy to use and well documented ( http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Math.html ).

    You can use it like this
    Code:
    var dx:Number = 40;
    var dy:Number = 5;
    
    var a:Number = Math.atan2(dy, dx) * 57.296; // angle
    var d:Number = Math.sqrt(dy * dy + dx * dx); // distance
    
    trace (a);
    trace (d);
    The functions it has are static functions so you don't create an instance of the class but call the functions directly.

  4. #4
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Not really trying to solve a problem, just looking for how someone might apply the class in a Koolmoves Project and not so much the science. Looking more for how trig might be applied.

    I think it goes to the problem of lifting math out the classroom and into real life. Once that is done it becomes useful. Otherwise it remains a set of formulas on paper.
    Last edited by etuom; 08-21-2009 at 10:15 AM.

  5. #5
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    just wanted to add this.

    In the American Public Education system they taught math strictly as a science, at least where I went to school at the time. Endless formulas and crunching numbers which apparently had no point. As a result, I didn't pursue math as I didn't have a basis to appreciate the usefulness of it. Later, I began to appreciate it but was way behind the learning curve and so began to teach myself trigonometry with a view to using it in my work. Hard to do in your 40's.

    So maybe this will explain a little where I am coming from, particularly those who don't have the same experience.

  6. #6
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Later, I began to appreciate it but was way behind the learning curve
    Here's a little more . . .
    About 8 years ago I was on a painting job and ran out of material that was pretty expensive. The only thing left to do was a log handrail and it was of significant length. All cylinders. I couldn't afford to guess. My partner remembered how to find the surface area of a cylinder so we measured it all up and got the square footage with the formula, figured we need two more gallons and it turned out just right, no waste, no more trips, no lost time. I thought that was very cool and determined to start getting math back into my work and everyday life.

    Gee Wilbert, you sure know how to get people to talk!
    Last edited by etuom; 08-21-2009 at 11:08 AM.

  7. #7
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Quote Originally Posted by etuom
    Gee Wilbert, you sure know how to get people to talk!


    Math.min and Math.max can be useful to limit values.

    Math.atan2 can be used to calculate an angle if you want to rotate a movieclip in the direction of another object.

    Math.random can be used to get a random number.

    There's lots of situations where math is useful.

  8. #8
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Thanks Wilbert,
    There's lots of situations where math is useful
    .

    As can be seen if one takes a look at some of the classes that ship with Koolmoves! On a hunch I looked at the Necro classes and saw it used and then looked at your component classes and saw it used there as well.

    Here is a tutorial found here at flashkit that uses Math for "eyes that follow the cursor". It's for Flash users but it shows the code if anyone is interested.

    http://www.flashkit.com/tutorials/Ma...-738/index.php

    So with that I'll have to bow out of this thread as I'm feeling spread too thin. (that's almost poetic, thread - spread ) I would still be interested to see examples in Koolmoves if anyone is inclined.

  9. #9
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    My thumbnail class uses ceil to round up when calculating the need rows.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center