POV-Ray : Newsgroups : povray.general : an extraordinary rotation question : Re: an extraordinary rotation question Server Time
30 Jul 2024 08:23:29 EDT (-0400)
  Re: an extraordinary rotation question  
From: Tim Attwood
Date: 19 Jun 2009 19:02:19
Message: <4a3c18fb@news.povray.org>
For exact alignments of object you need the
correct coordinates for the desired "seam" corner.
In the example you provided one of the corners is
at <-49.999,-49.999,0.001>, and another at
<50.001,50.001,100.001>.  

The first thing you are doing with "box_"
is redeclaring it as BOX.
#declare BOX = object { box_  scale <0.01,0.01,0.01> translate <0, 0, 0> }
When you scale you are relocating the corners around the origin by
multiplication. So 
0.01*<-49.999,-49.999,0.001> = <-0.5,-0.5,0>, and
0.01*<50.001,50.001,100.001> = <0.5,0.5,1>
Then translate <0,0,0> does nothing at all.

So then you have your first wall so you scale by
<250,260,10>... so
<250,260,10>*<-0.5,-0.5,0>= <-125,-130,0>, and
<250,260,10>*<0.5,0.5,1>=<125,130,10>
which you then translate... so addition
<-125,130,-3.5>+<-125,-130,0> = <-250,0,-3.5>, and
<-125,130,-3.5>+<125,130,10>=<0,260,6.5>
So the first wall is equivalent to 
box{<-250,0,-3.5>,<0,260,6.5>}

So then you have your second wall, which
you scale to size <200,260,15>
so now you have an equivalent
box {<-100,-130,0>,<100,130,15>}
Because BOX is siting on the origin, the center 
of the scaled box is still sitting on the origin,
but the corner you want to rotate around isn't.
So for this example I'll pick a corner... <-100,-130,0>
What you want to do is take that corner and
put it on the origin... so
translate <100,130,0>
then rotate it by some angle say 
rotate y*45
and then put that corner on a corner from the first
wall... say <-250,0,-3.5> so 
translate <-250,0,-3.5>

So to summarize, something like

// first wall
box{<-250,0,-3.5>,<0,260,6.5>}

// second wall
box {<-100,-130,0>,<100,130,15>
   translate <100,130,0>
   rotate y*45
   translate <-250,0,-3.5>
}

But where does that leave the other
corner of the second wall? Before we
rotated it we knew it was at <200,260,0>,
but there's math involved, that could get
complicated. Fortunately, POV has a function
to figure it out for us... vrotate....
so the other corner is at
vrotate(<200,260,0>,y*45)+<-250,0,-3.5>
So, for the third wall you'd translate it to there.


Post a reply to this message

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