|
![](/i/fill.gif) |
In article <39a1d84c@news.povray.org>, "Halbert" <hha### [at] capital net>
wrote:
> Psuedocode plagerized from Computer Graphics and Principals 2nd Edition:
...snip...
> This should be easily converted into a macro (assumming I haven't
> made too many typing errors.)
Whee, Pascal...the last time I read Pascal I was trying to convert a
demo program written in it to C. It was surprisingly easy, actually...
Here is an untested attempt at a straight conversion to POV:
#macro RGB2HSV(RGB)
#local Max = max(RGB.r, max(RGB.g, RGB.b));
#local Min = min(RGB.r, min(RGB.g, RGB.b));
#local V = Max;
#if(Max != 0)
#local S = (Max - Min)/Max;
#else
#local S = 0;
#end
#if(S = 0)
#local H = 0;
#else
#local Delta = Max - Min;
#if(RGB.r = Max)
#local H = (RGB.g - RGB.b)/Delta;
#else
#if(RGB.g = Max)
#local H = 2 + (RGB.b - RGB.r)/Delta;
#else
#if(RGB.b = Max)
#local H = 4 + (RGB.r - RGB.g)/Delta;
#end
#end
#end
#local H = H*60;
#if(H < 0)
#local H = H + 360;
#end
#end
(< H, S, V>)
#end
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
![](/i/fill.gif) |