POV-Ray : Newsgroups : povray.newusers : Declaration type Server Time
31 Jul 2024 08:28:02 EDT (-0400)
  Declaration type (Message 1 to 4 of 4)  
From: Kaveh
Subject: Declaration type
Date: 16 Nov 2002 00:23:56
Message: <1flqk0y.1vw6141xu6fckN%kaveh@delete_this.focalimage.com>
I find that I can use the following code:

#declare a = 1;
#sphere {a,a pigment{color rgb a}}

Furthermore, the following code:

#declare a = 1;
#sphere {a.x,a pigment{color rgb a}}

gives the same result, i.e. a.x gives the x component, which is 1, which
is then re-interpreted as the vector <1,1,1>

Obviously not good style, but is "a" held internally both as a float and
as a vector? I appreciate any insight into this.

-- 
Kaveh


Post a reply to this message

From: hughes, b 
Subject: Re: Declaration type
Date: 16 Nov 2002 01:14:02
Message: <3dd5e22a$1@news.povray.org>
"Kaveh" <kav### [at] delete_thisfocalimagecom> wrote in message
news:1flqk0y.1vw6141xu6fckN%kaveh@delete_this.focalimage.com...
>
> #declare a = 1;
> #sphere {a.x,a pigment{color rgb a}}
>
> gives the same result, i.e. a.x gives the x component, which is 1, which
> is then re-interpreted as the vector <1,1,1>
>
> Obviously not good style, but is "a" held internally both as a float and
> as a vector? I appreciate any insight into this.

I believe it is interpreted at the place where it is used, as in the
position of a sphere being a vector if given only a float and same for
color. I don't think a declared float is stored as a vector since it would
be an error if used for other things that require a nonvector.


Post a reply to this message

From: Mark Wagner
Subject: Re: Declaration type
Date: 16 Nov 2002 23:36:55
Message: <pan.2002.11.17.04.35.51.438570.214@gte.net>
On Sat, 16 Nov 2002 00:23:50 -0500, Kaveh quoth:

> I find that I can use the following code:
> 
> #declare a = 1;

This creates a variable named "a" that stores the value "1" as a
double-precision floating-point number.

> #sphere {a,a pigment{color rgb a}}

This uses "a" as a color, so it gets promoted to the 5 component vector
<1,1,1,0,0> temporarily.  It's still stored as a float.


> Furthermore, the following code:
> 
> #declare a = 1;
> #sphere {a.x,a pigment{color rgb a}}
> 
> gives the same result, i.e. a.x gives the x component, which is 1, which
> is then re-interpreted as the vector <1,1,1>

a.x is a vector expression, so "a" gets promoted to the 3 component
vector <1,1,1>.  It's still a float.  See section 6.1.4.4 "Operator
promotion" of the manual for more information.

-- 
Mark


Post a reply to this message

From: Kaveh
Subject: Re: Declaration type
Date: 17 Nov 2002 04:47:28
Message: <1flst3j.1wg16mg1qgkbuoN%kaveh@delete_this.focalimage.com>
Mark Wagner <mar### [at] gtenet> wrote:

[...]

> a.x is a vector expression, so "a" gets promoted to the 3 component
> vector <1,1,1>.  It's still a float.  See section 6.1.4.4 "Operator
> promotion" of the manual for more information.

Thank you Mark. It's the 'temporary promotion' that explains it. I will
look at the manual.

-- 
Kaveh


Post a reply to this message

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