/* tetra.pov */ #include "colors.inc" #include "functions.inc" #include "transforms.inc" /* planepts(a, b, c) * * Creates a plane passing through points 'a', 'b', and 'c'. * * Normal direction calculated according to left-hand rule. */ #macro planepts(a, b, c) plane { y, 0 Reorient_Trans(y, vcross(c - a, b - a)) translate a } #end /* tetrasolid(a, b) * * Creates a solid tetrahedron inscribed in a box with opposite corners located * at 'a' and 'b'. */ #macro tetrasolid(a, b) intersection { planepts(, , ) planepts(, , ) planepts(, , ) planepts(, , ) bounded_by {box {a, b}} } #end /* tetraframe(a, b, rad) * * Outlines a tetrahedron as would be created by tetrasolid('a', 'b') with * cylinders of radius 'rad'. */ #macro tetraframe(a, b, rad) merge { sphere {, rad} sphere {, rad} sphere {, rad} sphere {, rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} } #end /* boxframe(a, b, rad) * * Outlines a box as would be created by box {'a', 'b'} with cylinders of * radius 'rad'. */ #macro boxframe(a, b, rad) merge { sphere {, rad} sphere {, rad} sphere {, rad} sphere {, rad} sphere {, rad} sphere {, rad} sphere {, rad} sphere {, rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} cylinder {, , rad} } #end #macro arrow(a) union { cylinder {0, a, 1/32} cone {a - vnormalize(a) * 0.3, 1/16, a, 0} } #end #macro tetramonkey(a, b, rad) union { object { tetraframe(a, b, rad) pigment {color White} } object { tetrasolid(a, b) pigment {rgbt <0, 0, 1, 0.5>} } object { boxframe(a, b, rad / 2) pigment {rgbt <0, 1, 1, 0.9>} } box { a, b pigment {rgbt <1, 0, 0, 0.9>} } } #end /* Create the pyramid thing. */ union { object {tetramonkey(<0, 0, 0>, <1, 1, 1>, 1/32)} object {tetramonkey(<1, 1, 0>, <2, 2, 1>, 1/32)} object {tetramonkey(<1, 0, 1>, <2, 1, 2>, 1/32)} object {tetramonkey(<0, 1, 1>, <1, 2, 2>, 1/32)} translate -1 Reorient_Trans(<-1, 1, 1>, y) translate y * 2 } /* Create the floor. */ plane { y, 0 pigment { checker color Gray50, color Gray40 scale 1/4 } } fog { fog_type 1 distance 30 color White } light_source { y * 100, color White parallel point_at -y } camera { location <0, 3, -3.1> * 1.4 look_at <0, 1.5, 0> rotate y * clock * -360 } global_settings { max_trace_level 10 } /* vim: set ts=4 sts=4 sw=4 tw=80 et: */