POV-Ray : Newsgroups : povray.binaries.images : something to share... : Re: something to share... Server Time
2 Oct 2024 00:18:34 EDT (-0400)
  Re: something to share...  
From: Warp
Date: 3 Jul 2000 18:32:24
Message: <39611478@news.povray.org>
Ian Witham <ian### [at] hotmailcom> wrote:
: BTW.. just try placing a POV cube so that two opposite corners lie on the y
: axis. It's trickier than it sounds.

  It requires some math.

  One may think that just rotate 45 degrees around x axis and then 45 degrees
around z axis, but one will soon discover that it's not so easy (when trying
to render it).

  The first step was right: rotating 45 degrees around the x axis makes the
diagonal to lay on the x-y plane. Now we only need to rotate it around the
z axis so that the diagonal is parallel to the y axis.
  The reason why 45 degrees is not correct is because the diagonal
is not 45 degrees from the y axis anymore. This is because now the diagonal
is higher than it's wide.
  More precisely the diagonal is 2*1 units wide while it's 2*vlength(<1,1,0>)
units high (supposing we have a -1,1 cube).
  The degree is precisely asin(width/length), ie. asin(1/vlength(1,1,1)).

  Now we only have to translate the box up so that the corner will be located
at the origin. Since we have the length of the diagonal (2*vlength(<1,1,1>)),
that's easy.
  In povray code it will be:

camera { location <-2,4,-10> look_at y angle 35 }
light_source { <100,200,-300> 1 }
plane { y,0 pigment { checker rgb 1, rgb .5 } }

box
{ -1,1 pigment { rgb <1,1,0> }
  rotate x*45
  #declare len = vlength(<1,1,1>);
  rotate z*degrees(asin(1/len))
  translate y*len
}

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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