Hi,
Let's say I have a variable coordinate=234321, and a variable scale=5000 (a constant, but should also be able to be e.g. 4000). Now, I want to translate this coordinate into an interval [-scale/2, +scale/2] that can contain it, starting on an even 10000nd of the coordinate itself.
So for example, in the case of 234321, the interval would be [232500,237500]. 234321 is inside that interval. Another example would be 239580 => [237500,242500]. One caveat though, this last example would also be satisfied in [235000,240000], however since it's more closer to the mean of that first interval, that should be the preferred one. So the function should kind of decide what interval to return depending on if it's on either side of a "scale/4" value or not, if you get what I mean. How can I write a generic function, that can take a coordinate and a scale as inputs, and produce this interval as an output?
Let's say I have a variable coordinate=234321, and a variable scale=5000 (a constant, but should also be able to be e.g. 4000). Now, I want to translate this coordinate into an interval [-scale/2, +scale/2] that can contain it, starting on an even 10000nd of the coordinate itself.
So for example, in the case of 234321, the interval would be [232500,237500]. 234321 is inside that interval. Another example would be 239580 => [237500,242500]. One caveat though, this last example would also be satisfied in [235000,240000], however since it's more closer to the mean of that first interval, that should be the preferred one. So the function should kind of decide what interval to return depending on if it's on either side of a "scale/4" value or not, if you get what I mean. How can I write a generic function, that can take a coordinate and a scale as inputs, and produce this interval as an output?