User Tag List

Results 1 to 10 of 10

Thread: MMF math

  1. #1
    No Products Registered

    Join Date
    Aug 2010
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MMF math

    I am working on a parabola trajectory setup and could do with some MMF-style math help.

    Plotting X,Y of an object path is done. I have a nice, time controlled (as opposed to frame rate) flight.
    I would like to be able to calc the angle of the object to set its angle.

    My approach is to set variables X1, Y1 then, a 1/100th later, X2, Y2.
    Angle = A
    tanA = opposite/adjacent = (X2-X1)/(Y2-Y1)

    So, how to get the angle? Or is there a better way?

    EDIT_______
    Poking around a few math forums/sites it seems I am looking for inverseTan. Beats me if I can find an actual formula that converts the ratio to an angle.

  2. #2
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    Use atan2(). It takes the x and y (aka opposite and adjacent) and does an inverse tan with quadrant correction to get the original angle.

  3. #3
    Clicker Multimedia Fusion 2 Developer
    Jax's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    702
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    Just use aTan2.

    Was my example in the other thread any use to you?

  4. #4
    No Products Registered

    Join Date
    Aug 2010
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    Thanks Jax.
    >> my example in the other thread...
    I missed that. Just downloaded and will study after lunch. Thanks.

    Thanks Dynasoft
    This looks promising but does not smooth my furrowed brow

    Where in the expression editor do I get "atan2()"? Or, what is the actual arrangement of X, Y?

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    Either type it, or it's in retrieve data of the special object somewhere. You need a recent build, it was added in b248.

    The use is apparently: atan2(y2-y1, x1-x2)

  6. #6
    No Products Registered

    Join Date
    Aug 2010
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    Yes, special object > arc tangent y/x
    the use is indeed: atan2(y2-y1, x1-x2)

    The current game I am building was started in an earlier version and I have noticed some things that are 'different' in my recent upgrade. So, I am playing it safe - which means I don't have atan2 available.

    I am also curious about the math behind the calculation. So, my quest continues.

  7. #7
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    atan2() is just a version of atan() (the inverse tan function) which corrects for an x of 0 (causes a div/0 error normally, instead of being +/- 90 degrees) and looks for a negative x to support angles past +/-90 (atan falsely registers y/-x as being -y/x instead).

  8. #8
    No Products Registered

    Join Date
    Aug 2010
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    OK - I see that my old version has atan() lurking in the same location. I will try that.

    As to your other comments... WAY over my head - certainly on first read. I won't be using/allowing angles over 90 so imagine it will function well enough.

    Thanks for leading me on. I have been away from MMF for about a decade and am slowly getting up to speed with all the new functions.

    @Jax
    That works really well. I like the keyed adjustment - although I may have to give thought to player conflict. I am using standard trajectory formula:
    x = vt cosA
    y = vt sinA - ½ g t²
    I am planning a trace follower, or rocket fire and such and like being able to plot x/y along the way.

    Yours is simpler. Thanks.


  9. #9
    No Products Registered

    Join Date
    Aug 2010
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    The current hitch is setting X1/Y1,X2/Y2 to calc the angle.

    on press enter > set x1/y1 then
    every 12" > calc angle using ATan with x2/y2 then
    every 12" set x1 = x2, y1 = y2

    My thought is that the calc for the angle would be done first but this doesn't seem to be the case.

    Is there an easy way to store the position values for previous position?

    I am experimenting with setting a 'trace' dot and using its position but so far no luck.

    I am moving slowly ahead with this and will post a final example. I found a 'bullet widget' that works fine but this is a great learning exercise for me.
    Thanks for your help. ~AK

  10. #10
    No Products Registered

    Join Date
    Aug 2010
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: MMF math

    Bumping a bit here but i thought you might like to see my working example.

    http://www.buddhamind.info/mmf/AK_parabola-3.mfa

    The only thing I am thinking to add is a tracer behind the projectile. A line of fading dots that follow the parabola.

    This has been quite project for me. A great way to learn.

Similar Threads

  1. math!
    By Sevennemesis in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 3rd August 2012, 06:18 PM
  2. ellipse x,y math
    By arfa in forum Multimedia Fusion 2 - Technical Support
    Replies: 15
    Last Post: 21st December 2010, 12:33 PM
  3. Math in an RPG
    By Hordolur in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 11th February 2009, 08:15 PM
  4. Math Help Please!
    By kungsangun in forum File Archive
    Replies: 4
    Last Post: 2nd April 2008, 03:16 AM
  5. Need math help
    By LazyCoder in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 20th January 2008, 06:45 PM

Posting Permissions

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