POV-Ray : Newsgroups : povray.general : What is wrong with this? Server Time
30 Jun 2024 12:54:07 EDT (-0400)
  What is wrong with this? (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: TonyB
Subject: What is wrong with this?
Date: 1 Sep 1999 12:23:37
Message: <37CD3FCE.D2DF3923@panama.phoenix.net>
Hello. I am having a small math problem. All my life I have found this
to be true. I even tried it on paper, and it works.

A/2 + B/2 = (A + B)/2

Am I wrong? The reason I ask is because of something that happened to me
while playing with Jaime Vives' clouds. The line that reads:

#declare p=sky_color*.5+White*.5;

*can* be re-written as:

#declare p=(sky_color+White)/2;

right? At least according to my formula. But for some odd reason, POV
says NO. Try it. I will post an image to the corresponding group
shortly.

--
Anthony L. Bennett
http://welcome.to/TonyB

Non nova, sed nove.


Post a reply to this message

From: Jerome M  BERGER
Subject: Re: What is wrong with this?
Date: 1 Sep 1999 13:19:43
Message: <37CD6031.D2359752@enst.fr>
TonyB wrote:
> 
> Hello. I am having a small math problem. All my life I have found this
> to be true. I even tried it on paper, and it works.
> 
> A/2 + B/2 = (A + B)/2
> 
> Am I wrong? The reason I ask is because of something that happened to me
> while playing with Jaime Vives' clouds. The line that reads:
> 
> #declare p=sky_color*.5+White*.5;
> 
> *can* be re-written as:
> 
> #declare p=(sky_color+White)/2;
> 
> right? At least according to my formula. But for some odd reason, POV
> says NO. Try it. I will post an image to the corresponding group
> shortly.
> 
> --
> Anthony L. Bennett
> http://welcome.to/TonyB
> 
> Non nova, sed nove.

It depends on the way sky_color is defined and on the way povray treats
#declare... If sky_color is declared as a+b (no parethesis) and pov
simply replaces (the way it works in c/c++) the first line is in fact:
a+b*.5+White*.5
and the second is:
(a+b+White)/2
which is completely different...

Just my 2 cents

		Jerome

-- 
*******************************

* they'll tell you what can't * mailto:ber### [at] inamecom
* be done and why...          * http://www.enst.fr/~jberger
* Then do it.                 *
*******************************


Post a reply to this message

From: Ron Parker
Subject: Re: What is wrong with this?
Date: 1 Sep 1999 13:23:57
Message: <37cd612d@news.povray.org>
On Wed, 01 Sep 1999 10:19:45 -0700, Jerome M. BERGER wrote:
>It depends on the way sky_color is defined and on the way povray treats
>#declare... If sky_color is declared as a+b (no parethesis) and pov
>simply replaces (the way it works in c/c++)

It doesn't.  It computes the value of a+b at the time the #declare is
parsed and puts the result in the "variable."

I'd guess that it's something odd about the way division works with
vectors.  Try multiplying by .5 instead of dividing by 2.  If that
works, it's probably a bug that should be looked at.


Post a reply to this message

From: TonyB
Subject: Re: What is wrong with this?
Date: 1 Sep 1999 14:13:54
Message: <37CD598F.9B016B96@panama.phoenix.net>
> It doesn't.  It computes the value of a+b at the time the #declare is
> parsed and puts the result in the "variable."

As one would expect.

> I'd guess that it's something odd about the way division works with
> vectors.  Try multiplying by .5 instead of dividing by 2.  If that
> works, it's probably a bug that should be looked at.

It did not work. It still renders incorrectly.

--
Anthony L. Bennett
http://welcome.to/TonyB

Non nova, sed nove.


Post a reply to this message

From: TonyB
Subject: Re: What is wrong with this?
Date: 1 Sep 1999 15:33:48
Message: <37CD6C32.75264007@panama.phoenix.net>
I tried something new. I added the keyword "color" before the formula
and it set the values straight. I don't like this. How come without that
keyword the other expression works, and without it the compact one
doesn't? I did a #debug on the value of the #declare'd variables and
look at this:

 #declare b=(sky_color+White)/2;   //ugly
 #declare p=(sky_color*.5+White*.5);   //nice

 #debug concat("B = ",str(b.x,0,3)," ",str(b.y,0,3)," ",str(b.z,0,3),"
P = ",str(p.x,0,3)," ",str(p.y,0,3)," ",str(p.z,0,3),"\n")

See for yourselves how much B differs from P. I don't understand how
this can generate such different results. At any rate, when you add
"color" to the UGLY pigment declaration, it becomes NICE. :P

--
Anthony L. Bennett
http://welcome.to/TonyB

Non nova, sed nove.


Post a reply to this message

From: Ron Parker
Subject: Re: What is wrong with this?
Date: 1 Sep 1999 16:09:17
Message: <37cd87ed@news.povray.org>
On Wed, 01 Sep 1999 14:10:59 -0400, TonyB wrote:
>I tried something new. I added the keyword "color" before the formula
>and it set the values straight. I don't like this. How come without that
>keyword the other expression works, and without it the compact one
>doesn't? I did a #debug on the value of the #declare'd variables and
>look at this:
>
> #declare b=(sky_color+White)/2;   //ugly
> #declare p=(sky_color*.5+White*.5);   //nice
>
> #debug concat("B = ",str(b.x,0,3)," ",str(b.y,0,3)," ",str(b.z,0,3),"
>P = ",str(p.x,0,3)," ",str(p.y,0,3)," ",str(p.z,0,3),"\n")
>
>See for yourselves how much B differs from P. I don't understand how
>this can generate such different results. At any rate, when you add
>"color" to the UGLY pigment declaration, it becomes NICE. :P

I did this myself and discovered the same thing.  I went further and looked
at the parser to see why, and it is indeed a bug.

By the way, I didn't get the same results you did.  I determined that
when the expression is in parentheses, or in any other way doesn't start
with a token that explicitly identifies it as a color, it parses as
a vector which is then promoted to a color, but the promotion is not 
done correctly.

In parse.c, in the function Parse_RValue, in the case where Terms is 5,
(search for "case 5" without the quotes) there was a line that said

            Assign_Colour(*DataPtr, Local_Express);

This is wrong, because Assign_Colour is a memcpy and Local_Express is an
array of DBL's, not of COLC's, and doesn't have the same layout in memory.  
This should read like so instead

            for (i=0;i<Terms;i++)
    	      ((COLC *)(*DataPtr))[i]=(COLC)Local_Express[i];

Don't forget to add a declaration for i at the top of the function.

This message has been crossposted to povray.bugreports, but followups 
remain in povray.general.  Please keep any discussion in .general.


Post a reply to this message

From: TonyB
Subject: Re: What is wrong with this?
Date: 2 Sep 1999 09:48:01
Message: <37CE6B80.C9079871@panama.phoenix.net>
Oooh. This is so exciting. *I* found a bug. Wow... I'm overwhelmed. I must sit
down, oh, yeah, I'm already seated. I must faint... (thud...)

--
Anthony L. Bennett
http://welcome.to/TonyB

Non nova, sed nove.


Post a reply to this message

From: Ken
Subject: Re: What is wrong with this?
Date: 2 Sep 1999 09:56:22
Message: <37CE81B7.79A7DEC0@pacbell.net>
TonyB wrote:
> 
> Oooh. This is so exciting. *I* found a bug. Wow... I'm overwhelmed. I must sit
> down, oh, yeah, I'm already seated. I must faint... (thud...)
> 
> --
> Anthony L. Bennett
> http://welcome.to/TonyB
> 
> Non nova, sed nove.

Try not to get too excited about it. They are not supposed to be there.

-- 
Ken Tyler

See my 850+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Fabien Mosen
Subject: Re: What is wrong with this?
Date: 2 Sep 1999 12:01:24
Message: <37CE9F09.B708D880@skynet.be>
TonyB wrote:
> 
> Oooh. This is so exciting. *I* found a bug. Wow... I'm overwhelmed. I must sit
> down, oh, yeah, I'm already seated. I must faint... (thud...)

Fine.  Now go search for bugs in Win98, and come back when you got them
all... :)

There is another strange behaviour of pov with colors : 
 pigment {checker Red White} gives the default green/yellow checker !!!

but
 pigment {checker color Red color White} gives white and red, as
expected...

Fabien.


Post a reply to this message

From: Ron Parker
Subject: {checker Red White} (was Re: What is wrong with this?)
Date: 2 Sep 1999 12:51:42
Message: <37ceab1e@news.povray.org>
On Thu, 02 Sep 1999 18:00:09 +0200, Fabien Mosen wrote:
>TonyB wrote:
>> 
>> Oooh. This is so exciting. *I* found a bug. Wow... I'm overwhelmed. I must sit
>> down, oh, yeah, I'm already seated. I must faint... (thud...)
>
>Fine.  Now go search for bugs in Win98, and come back when you got them
>all... :)
>
>There is another strange behaviour of pov with colors : 
> pigment {checker Red White} gives the default green/yellow checker !!!
>
>but
> pigment {checker color Red color White} gives white and red, as
>expected...

Crossposted to bugreports, followups to general, as usual.

This was reported a long time ago but never resolved.  It's actually
bigger than you think: any time two or more colors appear in a row with
no intervening commas or other stuff, POV will happily parse them all 
away, keeping only the value of the last one.  This means you COULD say
something like "color Red green 1" to get yellow.  In fact, that usage
is documented (but uncommon in the real world, I suspect.) 

Unfortunately, you can also say "color Red Green" and get green.  This 
is not documented, and is probably a bug (the docs do say COLOUR_IDs 
should come first.)  Parse_Colour should probably UNGET and EXIT when
it gets a second instance of any of COLOUR_ID, rgb, rgbt, rgbf, rgbft, 
or a bare vector expression.  This would make rgb 1 red 0 legal as a 
shortcut for cyan, but make rgb 1 rgb 0 become two separate colors,
suitable for use in checkers or bricks or hexagons.


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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