Topic: Weird issue with DistanceBetweenPoints

Hello, I'm using
OnlineMapsUtils.DistanceBetweenPoints(Vector2     point1,  Vector2 point2)

to calculate the distance between some Vector2 longitude/latitude points.

It work fine for most of my values, but unexpectedly it fail on a couple of points, because it return a Nan value.
I've tried using doubles instead of Vector2 and it return a totally weird value.

I really don't know why, please can you check the picture in attachment and help me to understand what's going on?
Many thanks!

Re: Weird issue with DistanceBetweenPoints

Hello.

Thank you for the bug report.
The problem has been fixed.
In the next version this will work correctly.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Weird issue with DistanceBetweenPoints

Great!
Do you know when you will release the new version with this bug corrected?

Re: Weird issue with DistanceBetweenPoints

1-2 weeks.

This bug does not require the immediate release of a fix, because you can easily check for NaN on your side.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Weird issue with DistanceBetweenPoints

Yes, but unfortunatley I rely on DistanceBetweenPoints for some maths.
Anyway I'll wait, maybe if you have a minor update just for this bug it would be really appreciated

Re: Weird issue with DistanceBetweenPoints

Open the DistanceBetweenPoints method you are using.
At the end of the method there will be a check for NaN for Y.
Add the same check for X.
Example for a method using Vector2:

public static Vector2 DistanceBetweenPoints(Vector2 point1, Vector2 point2)
{
// ...
if (float.IsNaN(sizeX)) sizeX = 0; // <--- ADD THIS
if (float.IsNaN(sizeY)) sizeY = 0;
return new Vector2(sizeX, sizeY);
}

The same logic for the other methods.
Just copy-paste the check line for Y and replace Y to X.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Weird issue with DistanceBetweenPoints

Many thanks!
It work!
The best support ever!