Search Unity

Square Root runs 1000 times in ~0.01ms?

Discussion in 'Scripting' started by Matt-Downey, Aug 16, 2012.

  1. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    By what measure? I've been hearing a lot about how 'platform dependant' it was... but it does not in any way define what platform it is used on. It uses a fairly generic Vector3 class/struct that by no means is Unity3d specific.

    Meh, you win some you lose some.

    +1.
     
    Last edited: Mar 24, 2014
  2. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    821
    Fair enough; the sad part is that I'm actively using System.Math in the feature I'm currently working on. I think you're harping on the pseduo-code assertion too much though. I called it pseudo code because I typed it up in Firefox and didn't want to derail the thread over a potential syntax error that I missed; it's clearly C# code written against the UnityEngine assembly. I responded to the use of Mathf without thinking, but to be a little fair to myself I did respond because that's exactly what you asserted was a valid fix:

    Anyway, I'll gladly admit that you can use Math.Sqrt instead of Mathf.Sqrt to improve the accuracy of the distance algorithm. I don't change any of my other assertions, however, and am done with this thread. We're talking in circles about what is frankly a silly issue. If you are working on an application that requires a more accurate implementation of distance that's an entirely separate discussion from what was being discussed. We're getting into 'if you assume the roast beef to be perfectly spherical and in a vacuum' territory.