POV-Ray : Newsgroups : povray.general : Some simple geometric puzzles : Re: Some simple geometric puzzles Server Time
30 Jul 2024 08:28:44 EDT (-0400)
  Re: Some simple geometric puzzles  
From: Reactor
Date: 8 Jun 2009 16:50:01
Message: <web.4a2d7872d1236d666e92a2670@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> To be solved with SDL. No #includes, though. And of course the simpler
> the answer, the better. Try to solve these before looking at other people's
> answers... :)
>
> 1) Transform a "box { 0, 1 }" with one single 'rotate' so that the box
>    corner at <1,1,1> ends up exactly on the y axis.
>
> 2) Create 4 spheres of the same size so that 3 of them are sitting on
>    the x-z plane, each one touching the other two at one single point,
>    and the 4th sphere is on top of the three, touching all these other
>    three spheres at one single point each.
>
> 3) Add a fifth, smaller sphere to the previous scene so that it touches
>    all the four larger spheres at a single point each.
>
>   Commented code is preferable. :)
>
> --
>                                                           - Warp


WHAT???!  I'm not doing your homework!

An answer to number 1:

/****************************************************************************
Version: POV-ray 3.6 (official)
File: news_box_test.pov
Scene Description:   Transforms a "box { 0, 1 }" with one single 'rotate'
so that the box corner at <1,1,1> ends up exactly on the y axis.
Written by: Reactor
Date:  2009 June 08
****************************************************************************/

#version 3.6;


global_settings
{
    assumed_gamma 1.0
}


background{ color rgb <1,1,1> }

light_source
{
    <100,100,-100>
    color rgb <1,1,1>
}





// visual representation of standard axis
// red for +x, green for +y, blue for +z
union
{
cylinder{ <0,0,0>, <1,0,0>, .005    pigment{ color rgb <1,0,0> } }
cylinder{ <0,0,0>, <0,1,0>, .005    pigment{ color rgb <0,1,0> } }
cylinder{ <0,0,0>, <0,0,1>, .005    pigment{ color rgb <0,0,1> } }

cone{ <1,0,0>, .015, <1.1,0.0,0.0>, 0    pigment{ color rgb <1,0,0> } }
cone{ <0,1,0>, .015, <0.0,1.1,0.0>, 0    pigment{ color rgb <0,1,0> } }
cone{ <0,0,1>, .015, <0.0,0.0,1.1>, 0    pigment{ color rgb <0,0,1> } }

scale 4
}



union
{

    box // THE BOX
    {
        0, 1
        pigment{ color rgb <0.5,0.5,0.5> }
    }


    sphere // yellow sphere marking corner at <1,1,1>
    {
        <1,1,1>, .05
        pigment{ color rgb <1,1,0> }
    }

rotate <-45,0, 180/pi*asin(1/sqrt(3))>
// where 180/pi converts from radians to degrees,
// 1 is a side length, and sqrt(3) is the length of the long diagonal
// between opposite corners.
}



camera
{
    location  <4,2,-5>
    look_at   <1,1.5,1>
}



//--------------------------


-Reactor


Post a reply to this message

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