📣 Join 115,179 people tracking their training. or for full access & no ads.

FetchPoint: The Game

10 lurkers | 283 watchers
Nov 2013
9:53am, 14 Nov 2013
13,657 posts
  • Quote
  • Pin
fetcheveryone
Yay, I killed the thread with maths :-)
Nov 2013
9:59am, 14 Nov 2013
19,182 posts
  • Quote
  • Pin
eL Bee!
Some of us are missing from the [All Time] Leaderboard :(
Nov 2013
9:59am, 14 Nov 2013
1,567 posts
  • Quote
  • Pin
Drell
That's really interesting. You just have to make sure that arccos isn't fed a number larger than 1. But also interesting that the rounding error could take it over 1 in the first place.
Nov 2013
10:08am, 14 Nov 2013
13,658 posts
  • Quote
  • Pin
fetcheveryone
I tracked it down to the sin() function (and I expect the cos() function is equally troubled).

Here's how I calculate the distance between two points (hopefully the site won't truncate it). Both machines were producing identical numbers until the row with the sin() functions. I've added a line below that to pull the value back down to 1 if it's crept over. If by chance, the troubled line undercalculates the value, it will have the effect of slightly increasing the returned distance - but shouldn't fall over.

function calculateDistance($lat1,$lng1,$lat2,$lng2) {
if ($lat1==$lat2 && $lng1==$lng2) {
return 0;
}
$radlat1 = pi() * $lat1/180;
$radlat2 = pi() * $lat2/180;
$radlon1 = pi() * $lng1/180;
$radlon2 = pi() * $lng2/180;
$theta = $lng1-$lng2;
$radtheta = pi() * $theta/180;
$dist = sin($radlat1) * sin($radlat2) + cos($radlat1) * cos($radlat2) * cos($radtheta);

$dist = acos($dist);
$dist = $dist * 180/pi();
$dist = $dist * 60 * 1.1515;
return $dist;
}
Nov 2013
10:17am, 14 Nov 2013
13,659 posts
  • Quote
  • Pin
fetcheveryone
Right then, fix in place, flowers.log closely monitoring the situation, and eL Bee! installed in the all time leaderboard at number two. Although... given the vastness of the flowers bug, I may well give the existing trails six weeks to burn out, and then drop back to monthly and yearly leaderboards for 2014.
Nov 2013
10:19am, 14 Nov 2013
1,568 posts
  • Quote
  • Pin
Drell
Well any error from truncating down to 1 is going to be pretty small compared to the variation in the earth's radius :-)
Nov 2013
10:44am, 14 Nov 2013
16,196 posts
  • Quote
  • Pin
Night-owl
Well Fetch. I have no idea what you are talking about. But thankfully you do, and if it makes the game fairer even in 6 weeks time (ie. Christmas) Then that is good. :-)
Nov 2013
10:52am, 14 Nov 2013
229 posts
  • Quote
  • Pin
Ceratonia
That value (1.000000000000000222044604925031) is the smallest possible floating point number above 1 that can be represented with the amount of binary precision you have. So it's definitely a rounding error, exactly the kind of thing that can happen when you move code between different floating point libraries.
Nov 2013
11:36am, 14 Nov 2013
1,032 posts
  • Quote
  • Pin
Molesy - 41 sleeps until Christmas
So what were the "certain circumstances" that triggered the bug?
Nov 2013
11:39am, 14 Nov 2013
2,310 posts
  • Quote
  • Pin
CStar (600)
Ah, it all makes sense now. (No it doesn't. I haven't a clue what you mean, but thank you for sorting out the problem!)

About This Thread

Maintained by Naomi P

Useful Links

FE accepts no responsibility for external links. Or anything, really.

Related Threads

  • badges
  • fetchgames
  • fetchpoint
  • games
  • gps

Report This Content

You can report any content you believe to be unsafe. Please let me know why you believe this content is unsafe by choosing a category below.



Thank you for your report. The content will be assessed as soon as possible.



Back To Top

Tag A User

To tag a user, start typing their name here:
X

Free training & racing tools for runners, cyclists, swimmers & walkers.

Fetcheveryone lets you analyse your training, find races, plot routes, chat in our forum, get advice, play games - and more! Nothing is behind a paywall, and it'll stay that way thanks to our awesome community!
Get Started
Click here to join 115,179 Fetchies!
Already a Fetchie? Sign in here