POV-Ray : Newsgroups : povray.text.scene-files : Pursuit curve (was Rainy Sunday afternoon) : Re: Pursuit curve (was Rainy Sunday afternoon) Server Time
30 May 2024 11:23:39 EDT (-0400)
  Re: Pursuit curve (was Rainy Sunday afternoon)  
From: kurtz le pirate
Date: 1 Nov 2023 13:09:00
Message: <6542862c$1@news.povray.org>
On 01/11/2023 12:08, William F Pokorny wrote:
> On 10/31/23 06:07, kurtz le pirate wrote:
>> The code is here.
> 
> Thank you!
> 
> FWIW. Because my yuqk fork playpen doesn't ship with a color.inc file, I 
> first tried using the macro you included, hsb2rgb(), over CHSV2RGB(). I 
> had to change the bottom part some for it to run.
> 
> ...
>           #elseif ( _Hue>=300 & _Hue<=360) // Was ( ... _Hue<360) ?
>                  #local RED = C;
>                  #local GREEN = 0;
>                  #local BLUE = X; // 'x' is a vector ?
>          #else
>                  #debug concat("_Hue is ",str(_Hue,9,3),"\n")
>                  #error "_Hue out of range in convertion ! "
>          #end
> 
>          <(RED+m), (GREEN+m), (BLUE+m), 0, _Transmit>
> #end
> 
> I ended up grabbing the older color.inc macros and using those because 
> the colors looked better - like what you had posted - than did the 
> hsb2rgb() results.
> 
> I'm not going to dig into why the difference at the moment as I have 
> many other fires burning low. I need to return to those before I forget 
> too much! :-)
> 
> Bill P.
> 


Thank Bill you for your very pertinent comments !


First of all, this "hsb2rgb()" macro was not supposed to be in the code.
It's not used because i'm using the "CHSV2RGB()" in the Draw() macro.


Then, there's my mistake "x" vs "X". I'm ashamed. Apologies.


Now for another point. The correction "less than or equal to 360"
instead of "strictly lower to 360". I don't agree with that.

Let's say the hue is equal to 390°. With your modification, everything
above 360 becomes red, whereas 390 (which equals 360 + 30) should be
orange.

Do you agree ?

In fact, the value of "_hue" must simply be reduced to the interval
[0..360[.

So at the beginning of the macro I added :
	#local HUE = mod2(_Hue,360);

and it's this variable that's used in everything else.


I made a little code that draws colored squares with both methods and
compared them in Photoshop. There's no difference in color.


And now the most important point. There's an error in the code. A big
error. (Yes, one more). The formula used for calculating X is wrong :
	#local X = C - (1 - abs(mod(HUE/60,2) - 1));

The good one is :
	#local X = C * (1 - abs(mod(HUE/60,2) - 1));

X = C **multiply by** ...



Last remark. To reduce the hue between 0 and 360, I use my "mod2"
function, which ALWAYS returns a positive value.

#declare mod2 = function (x,y) { select(mod(x,y),mod(x,y)+y,mod(x,y)) }

Too many troubles with the standard mod() function ...





;)


-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

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