Comparing ratios to the Golden Ratio

Hi all,

I'm currently trying to write an equation or piece of logic which will allow me to test ratios against the Golden Ratio to find the closest match. The ratios I need to test range from 1:255 to 255:1 (to several decimal places) and I want to convert these ratios into a decimal (z) between 0 & 1, such that 0 is a perfect match (1:1.618) and 1 is a the furthest possible (255:1). All the z values should be positive, such that a ratio of 10:1 will return a result similar to 1:11.

The application of this is in testing whether the brightness of two parts of an image conform to the Golden Ratio. In practice most of the ratios will be much closer, say between 5:1 and 1:5, so it might suit a log(10) solution?

So, where x = left side of ratio and y = right side, how do I define z as this number between 0 & 1?

This is keeping me up at night!

Also mods, please move this thread if I'm in the wrong place.

Thanks,

Pietbot

Re: Comparing ratios to the Golden Ratio

Hey Pietbot.

One piece of advice I have regarding this is to use the definition of the ratio (in terms of square root of 5) and find a rational approximation to the square root factor.

Re: Comparing ratios to the Golden Ratio

Thanks chiro that's an interesting idea and I guess would help in terms of apportioning more of the scale to the lower ratios I expect to get.

Anyone have any ideas about the actual calculation needed here?

Pietbot