POV-Ray : Newsgroups : povray.newusers : Declaration type : Re: Declaration type Server Time
31 Jul 2024 06:24:58 EDT (-0400)
  Re: Declaration type  
From: Mark Wagner
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

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