POV-Ray : Newsgroups : povray.binaries.scene-files : RotateList.inc Server Time
2 Sep 2024 12:13:36 EDT (-0400)
  RotateList.inc (Message 1 to 5 of 5)  
From: Tom Bates
Subject: RotateList.inc
Date: 25 Nov 2001 04:24:05
Message: <3c00b8b5$1@news.povray.org>
As a result of frustration on my part and inspiration on
Bill DeWitt's part (see "Rotate list" in povray.general),
I've come up with a set of macros that allow easy
rotation of objects in arbitrary axis order.

The macros return a single rotation vector that will result
in the same object rotation as though you had used
multiple rotation statements.

I can turn this code:

object { MyObject
  rotate 30*y
  rotate <40,0,60>
}

Into this:

object { MyObject
  rotate yxz(30,40,60)
}

Admittedly, here it's not that big of an improvement.

However, when I wanted to store a rotation vector in a
variable to use later, it was prohibitively difficult to have
the rotations done in any order except x then y then z.

Now I can do this:

#declare ROT = yzx(20,30,40); // 20*y, 30*z then 40*z
//   ROT is now < 33.856616, -2.292945, 35.467006>
object { MyObject rotate ROT }


I mainly did these for myself, but thought others might
like them, too.  I hope some of you can find some use
out of these.

--
Tom Bates


Post a reply to this message


Attachments:
Download 'RotateList.inc.txt' (2 KB)

From: Frits van Bommel
Subject: Re: RotateList.inc
Date: 25 Nov 2001 04:48:54
Message: <3c00be86$1@news.povray.org>
Thanks, great work. Just one comment:

  #macro xyz(px,py,pz)
    #local vx = vrotate(vrotate(vrotate(x,px*x),py*y),pz*z);
    #local vy = vrotate(vrotate(vrotate(y,px*x),py*y),pz*z);
    #local vz = vrotate(vrotate(vrotate(z,px*x),py*y),pz*z);
    getrotation(vx,vy,vz)
  #end

could be done somewhat shorter like this

  #macro xyz(px,py,pz)
    <px,py,pz>
  #end

;-)
I imagine this is also faster, especially when used a lot.

    Frits van Bommel


Post a reply to this message

From: Tom Bates
Subject: Re: RotateList.inc
Date: 25 Nov 2001 13:41:32
Message: <3c013b5c$1@news.povray.org>
Frits van Bommel wrote:
> Thanks, great work. Just one comment:
>
>   #macro xyz(px,py,pz)
>     #local vx = vrotate(vrotate(vrotate(x,px*x),py*y),pz*z);
>     #local vy = vrotate(vrotate(vrotate(y,px*x),py*y),pz*z);
>     #local vz = vrotate(vrotate(vrotate(z,px*x),py*y),pz*z);
>     getrotation(vx,vy,vz)
>   #end
>
> could be done somewhat shorter like this
>
>   #macro xyz(px,py,pz)
>     <px,py,pz>
>   #end
>
> ;-)
> I imagine this is also faster, especially when used a lot.
>
>     Frits van Bommel
>

You're absolutely right.
I guess I got caught up in the uniformity of it.

On the other hand, I guess I thought that particular one
wouldn't get used much, anyway.
At least when I'm doing rotations, if I want the order to
be x,y,z I just use a straight vector.

--
Tom Bates


Post a reply to this message

From: Frits van Bommel
Subject: Re: RotateList.inc
Date: 25 Nov 2001 17:06:22
Message: <3c016b5e@news.povray.org>
"Tom Bates" <tho### [at] shawca> wrote in message
news:3c013b5c$1@news.povray.org...
> Frits van Bommel wrote:

[snip me explaining a shorter xyz]

> You're absolutely right.
> I guess I got caught up in the uniformity of it.
>
> On the other hand, I guess I thought that particular one
> wouldn't get used much, anyway.
> At least when I'm doing rotations, if I want the order to
> be x,y,z I just use a straight vector.

Well, it might be a good idea to use this one anyways, just to get used to
the macros...
Just a thought ofcourse.

    Frits van Bommel


Post a reply to this message

From: Brendan Hurley
Subject: Re: RotateList.inc
Date: 7 Dec 2001 00:40:08
Message: <3C1056C3.60B1F57D@saber.net>
Hey, Tom,

[snip]
> I've come up with a set of macros that allow easy
> rotation of objects in arbitrary axis order.

Got a copy....will try it out....will post sample of use soonest...like
next week?

Thanx,
      Brendan
-- 
Michael Brendan Hurley           ShadowDancerEnterprizes, LTD.
POV Site: http://www.geocities.com/mbrendanh/indxx01.html
Family:   http://www.saber.net/~mbhcgc/index.shtml
mbh### [at] sabernet


Post a reply to this message

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