Monday 15 August 2011

c++ - mapping value to a certain range -


For example, I have three variables: "x", "y" and "z". They are from certain limits {min, max} Now, I want to calculate a new variable, let's say that p = x + F * (yz), where there is something stagnant between F and 1. This new math variable "p" should be mapped to up to {minute, maximum} range. How do i do this

Edit 1

Generate numbers in the array:

  Population [D * id] = 0; Population [D * ID + N] = 0; Population [D * ID + 2 * N] = 0; Population [D * id + 1] = rndFloat (globalState, threadIdx.x, 4); Population [D * ID + 1] = 0; Population [D * ID + 2 * N + 1] = 0; For (Int i = 2; i   

A new variable computing:

 for  (int i = 0; i   

Index A, B, and C. are randomly selected. The important thing is the minimum and maximum limit for the notice and its dependence by the given index:

  float mins = -4 - 1/4 * ABS ((i-4) / 3)); Float max = 4 + 1/4 * ABS ((int (I-4) / 3));   

Where for every category I am replaced by A, B and C. To simplify

2 Edit, let's just say 3 variables are x, y and z which are in some range. Each variable has its own limit, I want to calculate the new variable p = x + F * (y-z) and it needs to map it appropriately to its range. How do i do this

It depends on what your minimum and maximum value is. For example, to map P to between 0 and 1:

  if (p; lt; 10) p / = 9.0 f; And if (P & lt; 100) p / = 99.0 f; And if (P & lt; 1000) p / = 99 9.0F;   

and so on ...

No comments:

Post a Comment