Search Unity

GetPointVelocity return bad values

Discussion in 'Physics' started by KenSteelyHunter, Jan 14, 2021.

  1. KenSteelyHunter

    KenSteelyHunter

    Joined:
    Dec 18, 2020
    Posts:
    4
    I dont know, its bug or I using the method incorrectly, but problem is this:

    I use, for example
    Code (CSharp):
    1. Vector3 a = rb.GetPointVelocity(hitsArray[i].point);
    and no matter what point of rb, even if you specify the origin point

    the value (а) is returned correctly if speed is greater than 0.0001 or less than -0.0001
    but if the speed gets closer to zero, the value starts to return a random value in the range from -9.9 to 9.9 (approximately)


    who knows how to fix this? :)
    Thanks
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Those values are correct, it's just that they're so small that are displayed in scientific notation:

    -1.147202E-06 = -1.147202 * 10^-06 = -0.000001147202

    And the other value is:

    -6.083139E-06 = -6.083139 * 10^-06 = -0.000006083139

    Physics calculations involve very small rounding errors due to the floating point arithmetic. Therefore velocities will never be exactly 0, but the value will be so close to it that the object won't effectively move.
     
    Last edited: Jan 15, 2021
    KenSteelyHunter likes this.
  3. KenSteelyHunter

    KenSteelyHunter

    Joined:
    Dec 18, 2020
    Posts:
    4
    oh

    right! xD
    Thanks you!
    I forgot that E is a degree and looked in a completely different direction
     
    Edy likes this.