 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tom Melly <tom### [at] tomandlu co uk> 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] monotix co za * 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Gail Shaw" <gsh### [at] monotix co za> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tom Melly <tom### [at] tomandlu co uk> 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] monotix co za * 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Gail Shaw" <gsh### [at] monotix co za> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tom Melly wrote:
>
> "Gail Shaw" <gsh### [at] monotix co za> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Tom Melly <tom### [at] tomandlu co uk> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"PoD" <pod### [at] merlin net au> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Tom Melly" <tom### [at] tomandlu co uk> wrote in message
news:3a7e8c51@news.povray.org...
> "PoD" <pod### [at] merlin net au> 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Scott Hill <sco### [at] ncgraphics net> 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] monotix co za * 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
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |