POV-Ray : Newsgroups : povray.general : unexpected rotation result Server Time
8 Aug 2024 18:19:26 EDT (-0400)
  unexpected rotation result (Message 1 to 10 of 48)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Tom Melly
Subject: unexpected rotation result
Date: 5 Feb 2001 05:07:48
Message: <3a7e7b74$1@news.povray.org>
I came across this one the other day (don't know how I'd missed this
"feature" before).

Basically, I expected the two following rotations to be identical:

rotate y * - 45 + 45
rotate y * (- 45 + 45)

However, only the second one limits the rotation to y (the behaviour I
expected), whereas the first rotates y then z. Does this seem odd to anyone
else? Why is the first statement equivalent to <0,-45,45> ? Don't you need
commas and/or chevrons for vectors involving more than one axis?

Confused of Putney.


Post a reply to this message

From: Gail Shaw
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 05:36:06
Message: <3a7e8216@news.povray.org>
Tom Melly <tom### [at] tomandlucouk> wrote in message
news:3a7e7b74$1@news.povray.org...
> I came across this one the other day (don't know how I'd missed this
> "feature" before).
>
> Basically, I expected the two following rotations to be identical:
>
> rotate y * - 45 + 45
> rotate y * (- 45 + 45)
>

I would guess that pov is doing the multiplication first then adding
45.  Hence it's doing rotate <0,-45,0> + 45.
whereas the brackets in the second force pov
to evaluate the -45+45 first and multiply with y second.

Gail
********************************************************************
* gsh### [at] monotixcoza              * System.dat not found.         *
* http://www.rucus.ru.ac.za/~gail/ * Reformat hard drive Y)es O)k  *
********************************************************************
* If at first you don't succeed, call it version 1.0               *
********************************************************************


Post a reply to this message

From: Tom Melly
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 05:45:28
Message: <3a7e8448$1@news.povray.org>
"Gail Shaw" <gsh### [at] monotixcoza> wrote in message
news:3a7e8216@news.povray.org...
>
> > rotate y * - 45 + 45
> > rotate y * (- 45 + 45)
> >
>
> I would guess that pov is doing the multiplication first then adding
> 45.  Hence it's doing rotate <0,-45,0> + 45.
> whereas the brackets in the second force pov
> to evaluate the -45+45 first and multiply with y second.
>

Ah, it would appear that my problem here was based on a more serious
underlying misunderstanding. I've always specified single-axis rotations as,
for example, rotate x * 45. I thought that this just meant rotate x 45
degrees. So what does rotate x*45 mean? 45 times what?


Post a reply to this message

From: Gail Shaw
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 05:56:48
Message: <3a7e86f0@news.povray.org>
Tom Melly <tom### [at] tomandlucouk> wrote in message
news:3a7e8448$1@news.povray.org...
>
>
> Ah, it would appear that my problem here was based on a more serious
> underlying misunderstanding. I've always specified single-axis rotations
as,
> for example, rotate x * 45. I thought that this just meant rotate x 45
> degrees. So what does rotate x*45 mean? 45 times what?
>

x is equivalent to <1,0,0> hence rotate x*45 is exactly the same
as saying rotate <1,0,0>*45 or rotate <45,0,0>

Gail
********************************************************************
* gsh### [at] monotixcoza              * System.dat not found.         *
* http://www.rucus.ru.ac.za/~gail/ * Reformat hard drive Y)es O)k  *
********************************************************************
* If at first you don't succeed, call it version 1.0               *
********************************************************************


Post a reply to this message

From: Tom Melly
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 05:58:55
Message: <3a7e876f@news.povray.org>
"Gail Shaw" <gsh### [at] monotixcoza> wrote in message
news:3a7e86f0@news.povray.org...

> x is equivalent to <1,0,0> hence rotate x*45 is exactly the same
> as saying rotate <1,0,0>*45 or rotate <45,0,0>
>

SHPINGGG! (sound of light going on in confused head)

Many thanks Hurricane Beach.


Post a reply to this message

From: PoD
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 06:02:35
Message: <3A7E8847.C9EFB12A@merlin.net.au>
Tom Melly wrote:
> 
> "Gail Shaw" <gsh### [at] monotixcoza> wrote in message
> news:3a7e8216@news.povray.org...
> >
> > > rotate y * - 45 + 45
> > > rotate y * (- 45 + 45)
> > >
> >
> > I would guess that pov is doing the multiplication first then adding
> > 45.  Hence it's doing rotate <0,-45,0> + 45.
> > whereas the brackets in the second force pov
> > to evaluate the -45+45 first and multiply with y second.
> >
> 
> Ah, it would appear that my problem here was based on a more serious
> underlying misunderstanding. I've always specified single-axis rotations as,
> for example, rotate x * 45. I thought that this just meant rotate x 45
> degrees. So what does rotate x*45 mean? 45 times what?

x = <1,0,0> so x*45 = <45,0,0>

As for the first problem, the POV parser uses normal precedence rules.
It does the multiplication first, then the addition.
y = <0,1,0> so y* -45 = <0,-45,0>
then it promotes the second 45 to a vector so that it can be added
45 becomes <45,45,45>
so the end result is <0,-45,0> + <45,45,45> = <45,0,45>

-- 
PoD.


Post a reply to this message

From: Gail Shaw
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 06:03:40
Message: <3a7e888c@news.povray.org>
Tom Melly <tom### [at] tomandlucouk> wrote in message
news:3a7e876f@news.povray.org...
>
> SHPINGGG! (sound of light going on in confused head)

Glad to have been of help.

> Many thanks Hurricane Beach.
>

ROFL. Haven't seen that one before.

Gail


Post a reply to this message

From: Tom Melly
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 06:19:45
Message: <3a7e8c51@news.povray.org>
"PoD" <pod### [at] merlinnetau> wrote in message
news:3A7E8847.C9EFB12A@merlin.net.au...

> As for the first problem, the POV parser uses normal precedence rules.
> It does the multiplication first, then the addition.
> y = <0,1,0> so y* -45 = <0,-45,0>
> then it promotes the second 45 to a vector so that it can be added
> 45 becomes <45,45,45>
> so the end result is <0,-45,0> + <45,45,45> = <45,0,45>
>

Yep, got it figured now. I'd never taken in that rotate y on its own meant
anything, so I'd misunderstood what the * in rotate y*45 meant (I vaguely
assumed it was to allow the parser to recognise a single vector
transformation).

That aside, intuitively, I would still have expected "rotate y * foo + bar"
to limit the rotations to the y axis. Still, now I know.....

All in all, it reminds me of what someone at work told me. He is an
experienced programmer and script writer, but he always uses brackets - e.g.

x := ((x*45) + 10)

When I asked him why, he said that a) he doesn't have to worry about someone
screwing up the parser, b) it makes the code clearer and c) why not?


Post a reply to this message

From: Scott Hill
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 11:15:25
Message: <3a7ed19d$1@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3a7e8c51@news.povray.org...
> "PoD" <pod### [at] merlinnetau> wrote in message
> news:3A7E8847.C9EFB12A@merlin.net.au...
>
> All in all, it reminds me of what someone at work told me. He is an
> experienced programmer and script writer, but he always uses brackets...
>

    Most experienced programmers/scripters do - it's the safest way to get
any language to do what _you want_, rather than what _it thinks you want_ !
E.g, what does 1+2*3-4 evaluate to ?

Scott.


Post a reply to this message

From: Gail Shaw
Subject: Re: unexpected rotation result
Date: 5 Feb 2001 14:39:50
Message: <3a7f0186@news.povray.org>
Scott Hill <sco### [at] ncgraphicsnet> wrote in message
news:3a7ed19d$1@news.povray.org...
>     Most experienced programmers/scripters do - it's the safest way to get
> any language to do what _you want_, rather than what _it thinks you want_
!
> E.g, what does 1+2*3-4 evaluate to ?
>


If the rules of precedence that I remember are correct then that equals 3,
but it's
not clear from a quick look. I tend to use brackets if there are more that 3
terms
in an expression, regardless of whether they are actually needed or not.

Gail
--
********************************************************************
* gsh### [at] monotixcoza              * System.dat not found.         *
* http://www.rucus.ru.ac.za/~gail/ * Reformat hard drive Y)es O)k  *
********************************************************************
* If at first you don't succeed, call it version 1.0               *
********************************************************************


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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