Perl: the Markov chain saw | |
PerlMonks |
in reply to Check whether two numbers are within a range
You could use Manhattan (a.k.a. L1) distance, that is, check if abs($x - $x0) + abs($y - $y0) <= $thresh, but the area where the expression is true is a square on the latitude/longitude grid. You could also use the Euclidean (L2) distance, i.e. sqrt(($x - $x0)**2 + ($y - $y0)**2) <= $thresh, which designates a circle with radius $thresh around the point ($x0, $y0).
On a very small scale, you can ignore the fact that the latitude and longitude grid describes a spheregeoid instead of a flat area and keep the assumptions above (about the square and the circle). If you are truly interested, you can find out the coordinates of the corners of the garage and check if the point falls inside the polygon described by those coordinates.
By the way, is your GPS precise enough to position your car when inside the garage?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Check whether two numbers are within a range
by stevieb (Canon) on Feb 26, 2021 at 17:04 UTC | |
by LanX (Saint) on Feb 26, 2021 at 17:20 UTC | |
Re^2: Check whether two numbers are within a range
by LanX (Saint) on Feb 26, 2021 at 17:24 UTC | |
by stevieb (Canon) on Feb 26, 2021 at 17:45 UTC | |
by LanX (Saint) on Feb 26, 2021 at 17:54 UTC | |
by stevieb (Canon) on Feb 26, 2021 at 18:32 UTC | |
by Fletch (Bishop) on Feb 26, 2021 at 19:02 UTC | |
by LanX (Saint) on Feb 26, 2021 at 19:28 UTC | |
|