dix: fix axis scaling.
For two axes [a, b] and [x, y] (inclusive), the formula to scale point P(ab)
to (x,y) is:
    (P - a)/(b - a) * (y - x) + x
And the whole end result rounded of course to get the integer we need.
			
			
This commit is contained in:
		
							parent
							
								
									93ef72fa26
								
							
						
					
					
						commit
						9c8a2be2c7
					
				| 
						 | 
				
			
			@ -175,8 +175,12 @@ rescaleValuatorAxis(int coord, AxisInfoPtr from, AxisInfoPtr to,
 | 
			
		|||
 | 
			
		||||
    if(fmin == tmin && fmax == tmax)
 | 
			
		||||
        return coord;
 | 
			
		||||
    return (int)(((float)(coord - fmin)) * (tmax - tmin + 1) /
 | 
			
		||||
                 (fmax - fmin + 1)) + tmin;
 | 
			
		||||
 | 
			
		||||
    if(fmax == fmin) /* avoid division by 0 */
 | 
			
		||||
        return 0;
 | 
			
		||||
 | 
			
		||||
    return roundf(((float)(coord - fmin)) * (tmax - tmin) /
 | 
			
		||||
                 (fmax - fmin)) + tmin;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue