POV-Ray : Newsgroups : povray.general : Some simple geometric puzzles Server Time
30 Jul 2024 10:15:07 EDT (-0400)
  Some simple geometric puzzles (Message 1 to 7 of 7)  
From: Warp
Subject: Some simple geometric puzzles
Date: 8 Jun 2009 14:45:35
Message: <4a2d5c4f@news.povray.org>
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


Post a reply to this message

From: Reactor
Subject: Re: Some simple geometric puzzles
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

From: Reactor
Subject: Re: Some simple geometric puzzles
Date: 8 Jun 2009 18:15:00
Message: <web.4a2d8cadd1236d666e92a2670@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



For the second one:

#local rad = 1;
union
{
 sphere{ <0, rad*sqrt(8/3), 0>,  rad   } // top one

// the other spheres are laid out as corners of an equilateral triangle.
// all start at the +z distance away from the center of the triangle (the
origin)
// the spheres are then rotated into place
 sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0,   0,0> }
 sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0, 120,0> }
 sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0,-120,0> }

translate <0,rad,0> // move up to x-z plane
pigment{ color rgb <0.5,1.0,0.5> }
}


I *think* I can think of one for the third, but I can't finish it now.

-Reactor


Post a reply to this message

From: clipka
Subject: Re: Some simple geometric puzzles
Date: 8 Jun 2009 18:20:00
Message: <web.4a2d8e59d1236d66de4a901d0@news.povray.org>
"Reactor" <rea### [at] hotmailcom> wrote:
> rotate <-45,0, 180/pi*asin(1/sqrt(3))>

slightly shorter:

  rotate <0,45,atan(sqrt(2))*180/pi>


Post a reply to this message

From: Warp
Subject: Re: Some simple geometric puzzles
Date: 9 Jun 2009 16:47:22
Message: <4a2eca5a@news.povray.org>
Reactor <rea### [at] hotmailcom> wrote:
>  sphere{ <0, rad*sqrt(8/3), 0>,  rad   } // top one

> // the other spheres are laid out as corners of an equilateral triangle.
> // all start at the +z distance away from the center of the triangle (the
> origin)
> // the spheres are then rotated into place
>  sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0,   0,0> }
>  sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0, 120,0> }
>  sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0,-120,0> }

  Can you explain in more detail how you came up with those magical
formulae?

-- 
                                                          - Warp


Post a reply to this message

From: Reactor
Subject: Re: Some simple geometric puzzles
Date: 9 Jun 2009 21:20:01
Message: <web.4a2f0a30d1236d66a6f47e80@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Reactor <rea### [at] hotmailcom> wrote:
> >  sphere{ <0, rad*sqrt(8/3), 0>,  rad   } // top one
>
> > // the other spheres are laid out as corners of an equilateral triangle.
> > // all start at the +z distance away from the center of the triangle (the
> > origin)
> > // the spheres are then rotated into place
> >  sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0,   0,0> }
> >  sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0, 120,0> }
> >  sphere{ <0, 0, rad*2/3*sqrt(3)>,  rad   rotate <0,-120,0> }
>
>   Can you explain in more detail how you came up with those magical
> formulae?
>
> --
>                                                           - Warp

I... no... not really.  I am really bad at explaining these things via
news/text, primarily because I have to be able to see or draw the shapes to
visualize them.  However, in lieu of a long-yet-poorly-worded description,
please accept these diagrams on my Povwiki talk page:
http://wiki.povray.org/content/User_talk:Reactor

I hope you can read my handwriting, if not I will try to decipher it myself and
transcribe it.

-Reactor


Post a reply to this message

From: Tim Attwood
Subject: Re: Some simple geometric puzzles
Date: 12 Jun 2009 16:37:42
Message: <4a32bc96$1@news.povray.org>
(1) After you rotate the box corner to the xz plane
the coordinates of the corner are now <sqrt(2),a>,
so to get the angle you just convert to polar coordinates,
there's a button for that on my caclulator.

(2) Three spheres form a triangle, the radius
of a circumscribed circle around a triangle is
a*sqrt(3)/3, so you have the first three spheres
by rotating them. Then four spheres form a
tetrahedron, the height of a tetrahedron is
a*sqrt(2/3), so you have the forth sphere.

(3) A sphere fit inside a tetrahedron (the insphere)
has a radius of a*0.5*sqrt(6), so we have the
location of the center sphere. Then the radius
of the circumsphere is a*sqrt(2/3), so that's the
distance from the center to the corners, and
the radius of the inner sphere is that distance
minus the bigger sphere radius.

#include "colors.inc"

global_settings {
  assumed_gamma 1.0 
  max_trace_level 10
}
camera {
  location  <0.0, 1.5, -5.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.5,  0.0> 
}
light_source {
  <0, 0, 0>
  color rgb <1, 1, 1>
  translate <-30, 30, -30>
}

// ground plane
plane { y, 0 pigment {checker Tan Gray50}}

// a box with a single rotate
union {
   box {0,1 rotate <45,54.73561,90>} // (sqrt 2),1 -> toPolar
   cylinder {<0,0,0>,<0,100,0>,0.005} // axis marker
   pigment {Red} 
   translate -x
}

// four spheres (close packed tetrahedral)
#declare sRad = 0.5; // sphere radius
#declare a = 2*sRad; // tetrahedral side length
#declare r = 0.5773503*a; // circumscribed circle radius: a*sqrt(3)/3
#declare h = 0.816496*a; // height of tetrahedron: a*sqrt(2/3)
union {
   sphere {<0,sRad,r>,sRad}
   sphere {<0,sRad,r>,sRad rotate <0, 120,0>}
   sphere {<0,sRad,r>,sRad rotate <0,-120,0>}
   sphere {<0,h+sRad,0>,sRad}

// a sphere inside four close packed spheres
   #declare ir = 0.204124*a; // inradius: a*0.5*sqrt(6)
   #declare cs = 0.6123724*a; // circumsphere radius: a*sqrt(2/3)
   sphere {<0,ir+sRad,0>,cs-sRad pigment {Blue}}
   pigment {Green transmit 0.5}
   translate x
}


Post a reply to this message

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