Expand a number?
I am not sure what this is called in math, but here I go.
e.g. Map sizes
10 *.5 = 5;
10 * 2 = 20;
now what I need to do is remap an incoming value to map to the correct integer.
If I pass in 5 to a function that I had used .5 to reduce the map size to I would get 10,
now
If I pass in 20 to a function that I had used 2 to expand the map size to I would get 10
I am not sure what the math of this would be for I have beaten my head into the wall for a few hrs...
Thanks
Maybe it will help to see it as:
5 * 1/.5 = 10
20 * 1/2 = 10
Also:
.5 = 5/10
2 = 20/10
I'm pretty sure this is Algebra.
5 * 1/.5 = 10
20 * 1/2 = 10
Also:
.5 = 5/10
2 = 20/10
I'm pretty sure this is Algebra.
The only terms I can think of that might apply (though I'm really not clear what you are asking about) are "multiplication", "arithmetic", "inverse", "reciprocal", "scaling", or maybe "interpolation".
Sorry I must not have explained it well enough. But here is what I am trying to do
map size = 129x129
so if I scale the map with .5 or 2 to half or double the size and I pass in a value from the camera I need to access the array with the correct offset due to the terrain has been scaled.
this is what I have so far and is apparently wrong...
map size = 129x129
so if I scale the map with .5 or 2 to half or double the size and I pass in a value from the camera I need to access the array with the correct offset due to the terrain has been scaled.
unsigned int a = mapData.map_X / ((mapData.map_X * mapData.terrainScaleFactor) / x);unsigned int b = mapData.map_Z / ((mapData.map_Z * mapData.terrainScaleFactor) / z);
this is what I have so far and is apparently wrong...
unsigned int rescale(const unsigned int input_value){ return 10 * input_value; // ten times whatever}int main(){ unsigned int scaled; scaled = rescale(0.5); // scaled now contains 5 (10*0.5)}
[Edited by - AngleWyrm on June 8, 2007 1:42:34 AM]
0 1 2 3 4 5 6
scale it by 2
0 2 4 6
scale it by 1/2
0 1 2 3 4 5 6
Like this?
correctMap(129x129map) vector(2DINT) getRealPosition(vector(2DDouble)u){
werid stuff ... = Math.rint(u);
another weird stuf to do clamping.
another weird stuff for map selection.
}
Thought better way would be apply change of position into some state object, and then just query it.
Note you have array 129x129. 129 is 2^7 + 1. (The actual map is 128x128)
scale it by 2
0 2 4 6
scale it by 1/2
0 1 2 3 4 5 6
Like this?
correctMap(129x129map) vector(2DINT) getRealPosition(vector(2DDouble)u){
werid stuff ... = Math.rint(u);
another weird stuf to do clamping.
another weird stuff for map selection.
}
Thought better way would be apply change of position into some state object, and then just query it.
Note you have array 129x129. 129 is 2^7 + 1. (The actual map is 128x128)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement