User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Finding Distance

  1. #1
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Finding Distance

    Isn't the formula for finding the distance between two objects (X1+X2)-(Y1+Y2)? I can't remember off hand what it is and can't find the place I read it from before.

  2. #2
    No Products Registered

    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    1,141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Finding Distance

    Sqr((X1-X2) pow 2 + (Y1-Y2) pow 2)

  3. #3
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Finding Distance

    You could also use the "distance between two objects" expression of the clickteam movement controller.

    Regards Peter

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Finding Distance

    thats an inefficient algorithm. If you use it heavily, it will slow down your problem, because square roots take a while to calculate. Use this approximation algorithm from sketchy's snippet manager:

    ((Max(Abs((X(">Object 1<") - X(">Object 2<"))), Abs((Y(">Object 1<") - Y(">Object 2<"))))) * 0.941246) + ((Min(Abs((X(">Object 1<") - X(">Object 2<")) ), Abs((Y(">Object 1<") - Y(">Object 2<"))))) * 0.41)

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Finding Distance

    Sorry to disappoint you, Pixelthief, but that formula seems to be slower.

    A: Sqr((Random(1000)-Random(1000)) pow 2+(Random(1000)-Random(1000)) pow 2)
    B: ((Max(Abs((Random(1000)-Random(1000))), Abs((Random(1000)-Random(1000)))))*0.941246)+((Min(Abs((Random(1000)-Random(1000))), Abs((Random(1000)-Random(1000)))))*0.41)

    Set counter to *formula*, 50000 loops.

    A: 0.41 seconds
    B: 0.45 seconds

    The result differs of course, but I've tested it about 10 times - B was always slower.

    If you insist, I can upload my mfa. It utilizes QueryPerformaceCounter(), a WINAPI function that is very precise (using the DLL object).

    I've tested it with constants as well - same result.

  6. #6
    Clicker Multimedia Fusion 2 Developer

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

    Re: Finding Distance

    This is due to MMF's expression parsing being slower than performing a square root, and one expression being much more complex than the other.

    In MMF, I think "(X1-X2) pow 2" even manages to be faster than "(X1-X2) * (X1-X2)", when the reverse is true in compiled languages (e.g. c++).

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export ModuleUnicode Add-on
    Looki's Avatar
    Join Date
    Aug 2006
    Location
    Karlsruhe, Germany
    Posts
    3,741
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Finding Distance

    Yeah, I thought so.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleInstall Creator ProPatch Maker
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Crian's Avatar
    Join Date
    Oct 2009
    Posts
    415
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Finding Distance

    Hm, looks very interesting.

    Someone can put an example!
    please.
    _________________________
    Crian

  9. #9
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    UrbanMonk's Avatar
    Join Date
    May 2008
    Location
    Southern U.S.A.
    Posts
    847
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Finding Distance

    This is another reason to use lua.

  10. #10
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module
    RickyRombo's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere between here and there
    Posts
    3,167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Finding Distance

    Why not use ADO? (Advanced Direction Object)
    or Clickteam Movement controller as mentioned above?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Finding the distance between 2 identical objects
    By gkinfinity in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 29th December 2012, 11:08 PM
  2. Finding the closest value...
    By ChrisBurrows in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 7th June 2012, 06:27 PM
  3. Finding extensions
    By ASD in forum Extension Development
    Replies: 3
    Last Post: 17th November 2011, 04:46 AM
  4. Advanced Movement Object: Finding Distance
    By Gerblegod7 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 20th April 2007, 04:32 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
  •