/*
    Sondenhangar:

    Randbedingungen: 

    Platz eingeschränkt durch Hangars f. 1-Mann-Jäger. (16 m breit)
    sowie Außenhülle (Schräge ca. <18, 4.8> .. <26, 0>)
    1 m breiter Gang in der Mitte.

 */

#macro fach (b1, l1, r2)
    #local p000 = <-(b1/2-r2), r2,    r2>;
    #local p001 = <-(b1/2-r2), r2,    l1-r2>;
    #local p010 = <-(b1/2-r2), b1-r2  r2>;
    #local p011 = <-(b1/2-r2), b1-r2  l1-r2>;
    #local p100 = <+(b1/2-r2), r2,    r2>;
    #local p101 = <+(b1/2-r2), r2,    l1-r2>;
    #local p110 = <+(b1/2-r2), b1-r2  r2>;
    #local p111 = <+(b1/2-r2), b1-r2  l1-r2>;

    union {
	cylinder { p000, p001, r2 }
	cylinder { p010, p011, r2 }
	cylinder { p100, p101, r2 }
	cylinder { p110, p111, r2 }

	cylinder { p000, p010, r2 }
	cylinder { p001, p011, r2 }
	cylinder { p100, p110, r2 }
	cylinder { p101, p111, r2 }

	cylinder { p000, p100, r2 }
	cylinder { p001, p101, r2 }
	cylinder { p010, p110, r2 }
	cylinder { p011, p111, r2 }

	box { p000 - r2, p000 + r2 }
	box { p001 - r2, p001 + r2 }
	box { p010 - r2, p010 + r2 }
	box { p011 - r2, p011 + r2 }
	box { p100 - r2, p100 + r2 }
	box { p101 - r2, p101 + r2 }
	box { p110 - r2, p110 + r2 }
	box { p111 - r2, p111 + r2 }

	pigment { color Red }

    }

#end

#declare sonden_hangar_r =
    union {
	#local r1 = 13;
	#local b1 = 0.5;
	#local l1 = 2.0;
	#local r2 = 0.01;
	#local da = atan2(b1/2, r1) * 2;
	#local aa = atan2(1, 1) + da * 1.5;

	#while (r1*cos(aa + da/2) > 8.05)
	    #debug concat("\naa = ", str(aa, 0, 5))
	    #local hh = 0;
	    #while (hh < 4.8 - b1)
		object {
		    fach(b1, l1, r2)

		    translate <0, hh, r1>
		    rotate <0, degrees(aa), 0>
		}
		#local hh = hh + b1;
	    #end

	    #local aa = aa + da;
	#end

	#local r1 = 16;
	#local b1 = 0.5;
	#local r2 = 0.01;
	#local da = atan2(b1/2, r1) * 2;
	#local aa = atan2(1, 1) + da * 1.5;

	#while (r1*cos(aa + da/2) > 8.05)
	    #debug concat("\naa = ", str(aa, 0, 5))
	    #local l1 = 5.0;
	    #local hh = 0;
	    #while (hh < 3.1 - b1)
		object {
		    fach(b1, l1, r2)

		    translate <0, hh, r1>
		    rotate <0, degrees(aa), 0>
		}
		#local hh = hh + b1;
	    #end

	    #local l1 = 2.5;
	    #while (hh < 4.2 - b1)
		object {
		    fach(b1, l1, r2)

		    translate <0, hh, r1>
		    rotate <0, degrees(aa), 0>
		}
		#local hh = hh + b1;
	    #end

	    #local aa = aa + da;
	#end

    }

#declare sonden_hangar =
    union {
	object { sonden_hangar_r }
	object {
	    sonden_hangar_r
	    matrix <0, 0, 1,
	            0, 1, 0,
		    1, 0, 0,
		    0, 0, 0>
	}
    }
