POV-Ray : Newsgroups : povray.advanced-users : vector.x is a float, isn't it? Server Time
23 Dec 2024 15:32:23 EST (-0500)
  vector.x is a float, isn't it? (Message 1 to 7 of 7)  
From: slehar
Subject: vector.x is a float, isn't it?
Date: 13 Jul 2008 17:35:00
Message: <web.487a73ecc7f877ecf75a90cb0@news.povray.org>
Can someone please explain to me why I ***can't*** do this?

CODE >>>>
  #declare myVector = <1,2>

  atan2(myVector.y,myVector.x)
<<<< CODE

Parse Error: Expected 'operand', uv vector identifier found instead

But why I ***CAN*** do this?

CODE >>>>
  #declare myVector = <1,2>;
  #declare xValue = myVector.x;
  #declare yValue = myVector.y;

  atan2(yValue,xValue)
<<<< CODE

Works just fine!

Isn't myVector.x a plain float value that can be used wherever
a float is required?

  slehar


Post a reply to this message

From: Reactor
Subject: Re: vector.x is a float, isn't it?
Date: 13 Jul 2008 18:00:01
Message: <web.487a7a07d340be7bc2684d3b0@news.povray.org>
"slehar" <sle### [at] gmailcom> wrote:
> Can someone please explain to me why I ***can't*** do this?
>
> CODE >>>>
>   #declare myVector = <1,2>
>
>   atan2(myVector.y,myVector.x)
> <<<< CODE
>
> Parse Error: Expected 'operand', uv vector identifier found instead
>
> But why I ***CAN*** do this?
>
> CODE >>>>
>   #declare myVector = <1,2>;
>   #declare xValue = myVector.x;
>   #declare yValue = myVector.y;
>
>   atan2(yValue,xValue)
> <<<< CODE
>
> Works just fine!
>
> Isn't myVector.x a plain float value that can be used wherever
> a float is required?
>
>   slehar



You are correct that it "should" behave that way.  I know there is talk of
overhauling SDL and parsing for version 4.0.  Out of curiosity, have you tried
placing parenthesis? Such as:

atan2( (myVector.y) , (myVector.x) )
or even
atan2( (myVector.y + 0) , (myVector.x + 0) )

just off hand ideas, haven't tried it myself.


-Reactor.


Post a reply to this message

From: Chris B
Subject: Re: vector.x is a float, isn't it?
Date: 13 Jul 2008 18:22:14
Message: <487a8016@news.povray.org>
"slehar" <sle### [at] gmailcom> wrote in message 
news:web.487a73ecc7f877ecf75a90cb0@news.povray.org...
>
> Can someone please explain to me why I ***can't*** do this?
>
> CODE >>>>
>  #declare myVector = <1,2>
>
>  atan2(myVector.y,myVector.x)

#declare myVector = <1,2>;
#debug concat("myAngle: ", str(atan2(myVector.y,myVector.x),3,3),"\n")

writes "myAngle: 1.107" into the message stream for me on 3.6 under Windows.
What version are you running?

Regards,
Chris B.


Post a reply to this message

From: slehar
Subject: Re: vector.x is a float, isn't it?
Date: 14 Jul 2008 08:15:01
Message: <web.487b42e3d340be7bf75a90cb0@news.povray.org>
>  Out of curiosity, have you tried
> placing parenthesis? Such as:
>
> atan2( (myVector.y) , (myVector.x) )
> or even
> atan2( (myVector.y + 0) , (myVector.x + 0) )
>
> just off hand ideas, haven't tried it myself.
>
>
> -Reactor.

Nope, the parentheses don't fix it.


Post a reply to this message

From: slehar
Subject: Re: vector.x is a float, isn't it?
Date: 14 Jul 2008 08:20:01
Message: <web.487b4422d340be7bf75a90cb0@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote:
> "slehar" <sle### [at] gmailcom> wrote in message
> news:web.487a73ecc7f877ecf75a90cb0@news.povray.org...
>
> #declare myVector = <1,2>;
> #debug concat("myAngle: ", str(atan2(myVector.y,myVector.x),3,3),"\n")
>
> writes "myAngle: 1.107" into the message stream for me on 3.6 under Windows.
> What version are you running?
>
> Regards,
> Chris B.

Wow, thats bizarre! That code works for me too! But when I put the atan2( ) in
the density function where I need it, it doesn't work!

I'm running version 3.6.


Post a reply to this message

From: Chris B
Subject: Re: vector.x is a float, isn't it?
Date: 14 Jul 2008 09:05:44
Message: <487b4f28$1@news.povray.org>
"slehar" <sle### [at] gmailcom> wrote in message 
news:web.487b4422d340be7bf75a90cb0@news.povray.org...
> "Chris B" <nom### [at] nomailcom> wrote:
>> "slehar" <sle### [at] gmailcom> wrote in message
>> news:web.487a73ecc7f877ecf75a90cb0@news.povray.org...
>>
>> #declare myVector = <1,2>;
>> #debug concat("myAngle: ", str(atan2(myVector.y,myVector.x),3,3),"\n")
>>
>> writes "myAngle: 1.107" into the message stream for me on 3.6 under 
>> Windows.
>> What version are you running?
>>
>> Regards,
>> Chris B.
>
> Wow, thats bizarre! That code works for me too! But when I put the 
> atan2( ) in
> the density function where I need it, it doesn't work!
>
> I'm running version 3.6.

Ah. I'm not sure it's your problem, but x, y and z are the default parameter 
names used with a function, so I'd guess that they have a different meaning 
if used in a function definition or within function parameters.  You might 
want to try the equivalent colour vector component in your context on the 
off-chance that it'll work. It works ok in the following context:

#declare myVector = <1,2>;
#debug concat("myAngle: ", str(atan2(myVector.green,myVector.red),3,3),"\n")

Regards,
Chris B.


Post a reply to this message

From: Mike Williams
Subject: Re: vector.x is a float, isn't it?
Date: 15 Jul 2008 01:37:09
Message: <uwTQ+EB2cDfIFwU5@econym.demon.co.uk>
Wasn't it slehar who wrote:
>"Chris B" <nom### [at] nomailcom> wrote:
>> "slehar" <sle### [at] gmailcom> wrote in message
>> news:web.487a73ecc7f877ecf75a90cb0@news.povray.org...
>>
>> #declare myVector = <1,2>;
>> #debug concat("myAngle: ", str(atan2(myVector.y,myVector.x),3,3),"\n")
>>
>> writes "myAngle: 1.107" into the message stream for me on 3.6 under Windows.
>> What version are you running?
>>
>> Regards,
>> Chris B.
>
>Wow, thats bizarre! That code works for me too! But when I put the atan2( ) in
>the density function where I need it, it doesn't work!

The problem isn't the atan2(), you can't mention vectors inside a 
function. You can so this:

#declare mX = myVector.x;
#declare mY = myVector.y;

...
   function {
     ... atan2(mX,mY) ...
   }

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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