Construction of an octahedron

The octahedron is composed from two square based pyramids. The square based pyramids in turn are made from cutting away sections from a solid cube using planes. The trick aspect is calculating the correct equations for the planes!

The ground and sky are added to help distinguish the various faces of the octahedron. Below is the code for the construction of the pyramid

#declare planes = object{
    union{
        plane{<0,0.707,-0.5>,0}
        plane{<0.707,0,-0.5>,0}
            plane{<-0.707,0,-0.5>,-0.707}
            plane{<0,-0.707,-0.5>,-0.707}
                    }
}

#declare pyramid = object{
    difference{
        box{ <0,0,0>,<1,1,1>
              
            }
             object{planes            
                          }
    }
}