Given two floating point values zoomAmount
and zoomFactor
, I need to calculate a newZoomAmount
such that:
(newZoomAmount <= zoomAmount) && (newZoomAmount == pow( zoomFactor, i ))
for any integer i
. I can easily loop through the values or binary search through a table to find the answer. However: is there a closed form to accomplish this?
Motivation: The zoomFactor
is 2⅕</sup> ≅ 1.148698354997035
, so that each 5 "zoom in" events result in ~exactly a power of two increase. When zooming a diagram to fit on screen I want the zoom level to be one of these notches so that zooming out eventually lands exactly on the 'base' 1.0 zoom level.