POV-Ray : Newsgroups : povray.general : Q: dot operators Server Time
15 Nov 2024 21:14:28 EST (-0500)
  Q: dot operators (Message 1 to 7 of 7)  
From: Margus Ramst
Subject: Q: dot operators
Date: 17 Nov 1998 17:24:15
Message: <3651F7C6.78F3442@peak.edu.ee>
I don't know if this is a bug or not, but it I can't redefine a single component
of a vector with dot operators, i.e.:

#declare Vector = <0,0,0>;
#declare Vector.x = 5; //This sort of operation gives an error

I would expect it to result in <5,0,0>
I know this can be worked around, but I don't see why it should be illegal.

Margus


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: dot operators
Date: 17 Nov 1998 19:13:06
Message: <36521112.0@news.povray.org>
In article <365### [at] peakeduee> , Margus Ramst <mar### [at] peakeduee>  wrote:
>I don't know if this is a bug or not, but it I can't redefine a single component
>of a vector with dot operators, i.e.:
>
>#declare Vector = <0,0,0>;
>#declare Vector.x = 5; //This sort of operation gives an error
>
>I would expect it to result in <5,0,0>
>I know this can be worked around, but I don't see why it should be illegal.

Thats simple: Its not in the language definition!



    Thorsten




____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: Tho### [at] csicom


Post a reply to this message

From: Rich Lafferty
Subject: Re: dot operators
Date: 17 Nov 1998 19:45:49
Message: <365218bd.0@news.povray.org>
Thorsten Froehlich <fro### [at] charliecnsiitedu> wrote:
>In article <365### [at] peakeduee> , Margus Ramst <mar### [at] peakeduee>  wrote:

>> I don't know if this is a bug or not, but it I can't redefine a
>> single component of a vector with dot operators, i.e.:
>>
>> #declare Vector = <0,0,0>;
>> #declare Vector.x = 5; //This sort of operation gives an error
>>
>> I would expect it to result in <5,0,0>
>> I know this can be worked around, but I don't see why it should be illegal.
>
>Thats simple: Its not in the language definition!

Abstracting further:

Is a #define just macro substitution, like in C, or is it an
actual assignment operator?

  -Rich

-- 
Rich Lafferty ---------------------------------------------------------
IITS/Computing Services     | "Oderint dum metuant."
Concordia University        |            -- Lucius Accius (170-90 BC).     
ric### [at] vax2concordiaca -----------------------------------------[McQ]--


Post a reply to this message

From: Nieminen Mika
Subject: Re: dot operators
Date: 18 Nov 1998 06:10:02
Message: <3652ab0a.0@news.povray.org>
Rich Lafferty <ric### [at] vax2concordiaca> wrote:
: Is a #define just macro substitution, like in C, or is it an
: actual assignment operator?

  It definitely is not a macro substitution, because this doesn't work:

#declare Test=
texture
{ pigment { rgb 1 }
  normal { bumps .2 }
}

sphere
{ 0,1
  Test
}

  But you have to type this instead:

sphere
{ 0,1
  texture { Test }
}

-- 
                                                           - Warp. -


Post a reply to this message

From: Ron Parker
Subject: Re: dot operators
Date: 18 Nov 1998 08:18:28
Message: <3652c924.0@news.povray.org>
On 17 Nov 1998 19:45:49 -0500, Rich Lafferty <ric### [at] vax2concordiaca> wrote:
>Abstracting further:
>
>Is a #define just macro substitution, like in C, or is it an
>actual assignment operator?

It's an actual assignment operator.  POV parses whatever comes
after the #declare (not #define) and stores the binary result
of the parsing (i.e. an actual object, not a bit of text) in 
a chunk of memory referenced by an entry in the symbol table.  
When you use the #declared thing, POV copies this binary image 
and puts the copy into your scene, with any modifications you 
specify.

However, this doesn't actually have anything to do with the 
original question.  The stated behavior _could_ be implemented,
it just hasn't been.  Since it's just syntactic sugar and could
be accomplished other ways, I see no reason to implement it
except perhaps for parallelism with C.


Post a reply to this message

From: Margus Ramst
Subject: Re: dot operators
Date: 18 Nov 1998 20:40:33
Message: <36537750.366A8130@peak.edu.ee>
Of course it's not very important. I asked because I recently had to do sth.
like this:

#declare MyArray[Dim1][Dim2][Dim3][Dim4]=
        <MyArray[Dim1][Dim2][Dim3][Dim4].x,
         MyArray[Dim1][Dim2][Dim3][Dim4].y*Stuff,
         MyArray[Dim1][Dim2][Dim3][Dim4].z>;

This would be much more elegant:

#declare MyArray[Dim1][Dim2][Dim3][Dim4].y=
         MyArray[Dim1][Dim2][Dim3][Dim4].y*Stuff;

I'm just lazy, I guess...

Margus

Ron Parker wrote:
/.../
> Since it's just syntactic sugar and could be accomplished other ways, I see
> no reason to implement it except perhaps for parallelism with C.


Post a reply to this message

From: Dan Connelly
Subject: Re: dot operators
Date: 18 Nov 1998 21:53:20
Message: <36538816.64DE2D5B@flash.net>
You could do a macro solution :

#macro SetComponent3D(V1, C, V2)
  C * V2 + (<1, 1, 1> - C) * V1
#end

#declare MyArray[Dim1][Dim2][Dim3][Dim4] =
  SetComponent3D (
    MyArray[Dim1][Dim2][Dim3][Dim4],
    y,
    stuff * MyArray[Dim1][Dim2][Dim3][Dim4]
  )

Okay, so it's not terribly elegent, but perhaps
it's better than nothing....

Margus Ramst wrote:
> This would be much more elegant:
> 
> #declare MyArray[Dim1][Dim2][Dim3][Dim4].y=
>          MyArray[Dim1][Dim2][Dim3][Dim4].y*Stuff;
> 
> I'm just lazy, I guess...



-- 
http://www.flash.net/~djconnel/


Post a reply to this message

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