POV-Ray : Newsgroups : povray.programming : float constants in functions - bug and bugfix Server Time
8 Jul 2024 19:01:51 EDT (-0400)
  float constants in functions - bug and bugfix (Message 1 to 5 of 5)  
From: ABX
Subject: float constants in functions - bug and bugfix
Date: 5 Nov 2002 11:18:43
Message: <fqqfsuk77r6nhjj5chelpfj4d298ngdqda@4ax.com>
In documentation in chapter '6.1.6 User-Defined Functions' there is
FLOAT_BUILT-IN_IDENT as one of possible expressions. But only 'clock' and 'pi'
is recognized while chapter '6.1.3.4 Built-in Float Identifiers' lists much
more possible values. In order to fix it I have added following part in
expr_get_token function in long list of ifs.

#ifdef MISSED_FLOAT_CONSTANTS_RECOGNITION_PATCH
	else if(Token.Function_Id == CLOCK_DELTA_TOKEN)
	{
		Token.Token_Float = Clock_Delta;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == CLOCK_ON_TOKEN)
	{
		Token.Token_Float = (DBL) ( opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME );
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == FALSE_TOKEN)
	{
		Token.Token_Float = 0.0;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == FINALCLOCK_TOKEN)
	{
		Token.Token_Float = opts.FrameSeq.FinalClock;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == FINALFRAME_TOKEN)
	{
		Token.Token_Float = opts.FrameSeq.FinalFrame;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == FRAMENUMBER_TOKEN)
	{
		Token.Token_Float = opts.FrameSeq.FrameNumber;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == INITIALCLOCK_TOKEN)
	{
		Token.Token_Float = opts.FrameSeq.InitialClock;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == INITIALFRAME_TOKEN)
	{
		Token.Token_Float = opts.FrameSeq.InitialFrame;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == IMAGE_WIDTH_TOKEN)
	{
		Token.Token_Float = Frame.Screen_Width;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == IMAGE_HEIGHT_TOKEN)
	{
		Token.Token_Float = Frame.Screen_Height;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == NO_TOKEN)
	{
		Token.Token_Float = 0.0;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == OFF_TOKEN)
	{
		Token.Token_Float = 0.0;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == ON_TOKEN)
	{
		Token.Token_Float = 1.0;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == TRUE_TOKEN)
	{
		Token.Token_Float = 1.0;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == VERSION_TOKEN)
	{
		Token.Token_Float = opts.Language_Version / 100.0;
		return FLOAT_TOKEN;
	}
	else if(Token.Function_Id == YES_TOKEN)
	{
		Token.Token_Float = 1.0;
		return FLOAT_TOKEN;
	}
#endif 

ABX


Post a reply to this message

From: ABX
Subject: Re: float constants in functions - bug and bugfix
Date: 5 Nov 2002 11:20:58
Message: <6prfsusi70bnqgr2udqbhmqmkese6udb0b@4ax.com>
On Tue, 05 Nov 2002 17:16:11 +0100, ABX <abx### [at] abxartpl> wrote:
> I have added following part in
> expr_get_token function 

Of course in fnsyntax.cpp file.

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: float constants in functions - bug and bugfix
Date: 5 Nov 2002 12:16:56
Message: <3dc7fd08@news.povray.org>
In article <fqqfsuk77r6nhjj5chelpfj4d298ngdqda@4ax.com> , ABX 
<abx### [at] abxartpl>  wrote:

> In documentation in chapter '6.1.6 User-Defined Functions' there is
> FLOAT_BUILT-IN_IDENT as one of possible expressions. But only 'clock' and 'pi'
> is recognized while chapter '6.1.3.4 Built-in Float Identifiers' lists much
> more possible values.

Well, doesn't this make it a missing feature rather than a bug?  After all,
it simply isn't there.  Fixing the documentation is probably the better
solution.  Espeically the various "true" and "false" constants are really
not too useful in functions.  And "version" isn't a constant!

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: ABX
Subject: Re: float constants in functions - bug and bugfix
Date: 5 Nov 2002 12:33:03
Message: <l9vfsu8ohvekatj7gq5012l0pc5rgdgarr@4ax.com>
On Tue, 05 Nov 2002 18:16:52 +0100, "Thorsten Froehlich" <tho### [at] trfde>
wrote:
> Well, doesn't this make it a missing feature rather than a bug?

Oh, yes, I have even marked it with MISSED_FLOAT_CONSTANTS_RECOGNITION_PATCH

> Fixing the documentation is probably the better
> solution.

even if it can be easy fixed in sources and does not influence 'execution'
time for functions ?

> Espeically the various "true" and "false" constants are really
> not too useful in functions.

Some internal functions use switches as parameters. For example common SOR
switch. I have found this bug when I patched VM with new types of commands
where some of parameters were switches. Using 'on' is just much more readable
in scripts.

> And "version" isn't a constant!

Yes, my mistake, but why not to add this either as it works in SDL
expressions.

ABX


Post a reply to this message

From: Warp
Subject: Re: float constants in functions - bug and bugfix
Date: 5 Nov 2002 18:36:19
Message: <3dc855f3@news.povray.org>
Thorsten Froehlich <tho### [at] trfde> wrote:
> Well, doesn't this make it a missing feature rather than a bug?  After all,
> it simply isn't there.  Fixing the documentation is probably the better
> solution.  Espeically the various "true" and "false" constants are really
> not too useful in functions.  And "version" isn't a constant!

  IMO it would be good to add support for all the built-in variables
(constant or non-constant). It would not only be consistent, but also
handy (eg. a function could be created using frame_number or whatever).

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

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