POV-Ray : Newsgroups : povray.general : Simple math question : Re: Simple math question Server Time
30 Jul 2024 12:23:53 EDT (-0400)
  Re: Simple math question  
From: Mike Williams
Date: 15 Feb 2009 01:09:39
Message: <HRFnSJNFG7lJFwHy@econym.demon.co.uk>
Wasn't it some_yahoo who wrote:
>Trying to render something in a sequence of colors using an animation.
>Lets just say they are web buttons. I provide this color cube source to
>illustrate that I am getting a lot of missing colors.  What I really
>need is a function that converts a float (0..1) into an rgb value such
>that from 0 to 1 all colors are represented (with enough granularity).
>
>what I have so far is this, but the math is goofy somehow.

One thing that makes the math goofy is that cr and cr2 are not integers,
so the colours flop over at different points. I suspect that the only
way to fix that might be to choose KK to be one less than a perfect
cube.
  #declare KK=63; //number of steps total
And then adjust your K increment to match
  #declare K=K+1/(KK+1);

That gives you a results where each colour cycles through the values
  0.00
  0.25
  0.50
  0.75
but you really want to span the colour space 0-1 rather then 0-0.75, so
you need to multiply by cr/(cr-1)
  #declare C=<R,G,B>*cr/(cr-1);

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.