
mini=0.01;

mount_r=48;               //  radius
mount_th=10;              //  thickness

arm_w=18;                 //  width
arm_h=9;                  //  height
arm_shift=16;

arm1_l=72;                //  length
arm2_l=54;                //  length
arm3_l=24;                //  length
arm1_a=60;                //  angle
arm2_a=0;                 //  angle
arm3_a=-60;               //  angle

hole_r=3.6;               //  radius   min: 5.0 x 3.3
hole_w=hole_r*sqrt(3);    //  width    =6.2
hole_h=hole_r*3/2; ;      //  height   =5.4

arm4_l=18;                //  length
arm4_slant=1/12;

a1x=0;
a1z=-arm_shift;
a2x=a1x+arm1_l*cos(arm1_a);
a2z=a1z-arm1_l*sin(arm1_a);
a3x=a2x+arm2_l*cos(arm2_a);
a3z=a2z-arm2_l*sin(arm2_a);
a4x=a3x+arm3_l*cos(arm3_a);
a4z=a3z-arm3_l*sin(arm3_a);
a5x=a4x+arm4_l*cos(arm3_a);
a5z=a4z-arm4_l*sin(arm3_a);

holder_h=48;                    //  height
holder_r=18;                    //  radius
holder_h_int=24;                //  height - internal
holder_r_int=15;                //  radius - internal

size=1.6;  //  1.2 1.4 1.6  :  18 21 24

ring_h=16;                      //  height
ring_r=22;                      //  radius
//  ring_th=ring_r-holder_r;    //  thickness
ring_shift=6;
ring_slant=1/8;

hr1=holder_r+ring_slant*ring_shift;
hr2=holder_r+ring_slant*ring_h;
hr3=holder_r+ring_slant*(ring_shift+ring_h);

echo(holder_r,hr1,hr2,hr3);


base_h1=size*4;
base_h2=size*8;
base_h3=size*4;
base_h=base_h1+base_h2+base_h3;   //  height
base_r1=size*30;
base_r3=size*38;
base_bottom_r=size*29;            //  radius - internal
base_top_r=size*25;               //  radius - internal
base_w=1+size*1;                  //  width of spoke


//  ------------  wall mount and arms

module mount() {
difference() {
union() {
arms(arm_w,arm_h,0);
translate([a4x,0,a4z])
  arm4(arm4_l,arm3_a,arm_w,arm_h,arm4_slant);
//translate([1+mini,0,0])
rotate([0,90,0]) rotate(180)
  cylinder(mount_th,r=mount_r,$fn=9);
}
arms(hole_w,hole_h,mini);
translate([a4x,0,a4z]) {
  arm(arm4_l+mini,arm3_a,hole_w,hole_h,mini);
rotate([0,arm3_a,0])
translate([0,-hole_w/2,-hole_h/2])
  cube([arm4_l+mini,hole_w,arm_h]);
}
mount_hole();
z1=hole_h/2*cos(arm1_a);
z2=hole_h/2/cos(arm1_a);
z3=mount_th*tan(arm1_a);
translate([hole_r/2,0,-mount_r-arm_shift-z2+mini])
  cylinder(mount_r,r=hole_r,$fn=6);
rotate([90,0,0])
linear_extrude(hole_w,center=true)
polygon([[0,-arm_shift],[mount_th,-arm_shift-z2-z3],[0,-mount_r*cos(20)]]);
}
}
//mount();



//  ------------  bulb holder

module holder() {
difference() {

union() {
cylinder(ring_h,hr2,holder_r,,$fn=12);
translate([0,0,ring_h])
cylinder(holder_h-ring_h,r=holder_r,$fn=12);
//bulb();
}

translate([0,0,holder_h-holder_h_int]) {
  cylinder(holder_h_int,r=holder_r_int,$fn=12);
  mirror([0,0,1])
  cylinder(holder_r_int/sqrt(3),holder_r_int,0,$fn=12);
}
cylinder(holder_h,r=hole_r,$fn=6);

arm(arm3_l,180+arm3_a,arm_w+mini,arm_h+mini,mini);
arm4(arm4_l,arm3_a,arm_w+mini,arm_h+mini,arm4_slant);
}
}
//translate([a4x,0,a4z])
//holder();



//  ------------  shade base and ring

module base() {

difference() {
union() {
// = cylinder(base_h,r=base_r,$fn=48);
cylinder(base_h1,r=base_r1,$fn=48);
translate([0,0,base_h1])
cylinder(base_h2,base_r1,base_r3,$fn=48);
translate([0,0,base_h1+base_h2])
cylinder(base_h3,r=base_r3,$fn=48);
}
cylinder(base_h,base_bottom_r,base_top_r,$fn=12);
}

difference() {
cylinder(ring_h,r=ring_r,$fn=12);
cylinder(ring_h,hr3,hr1,$fn=12);
}

r_r=ring_r*cos(15)-mini;
r_h=ring_h-mini;
bb_r=base_bottom_r*cos(15)+mini;
//bt_r=base_top_r*cos(15)*ring_h/base_h+bb_r*(1-ring_h/base_h)+mini;
bt_r=bb_r;
for (i=[0:11])
rotate(15+i*30)
translate([0,base_w/2,0])
rotate([90,0,0])
linear_extrude(base_w)
polygon([[r_r,0],[r_r,r_h],[bt_r,r_h],[bb_r,0]]);

for (i=[0:2])
rotate(45+i*120)
translate([size*27.2*cos(15),0,base_h])
cube([2.4,2.4,6.4],center=true);

*rotate(0)
translate([0,0,base_h])
scale(size)
import("fire-02-B-simplify.stl");

}
//translate([a4x,0,a4z])
//translate([0,0,-ring_shift])
base();



//  ------------  arms

module arm(l,a,w,h,add) {
rotate([0,a,0])
translate([-add/2,-w/2,-h/2])
  cube([l+add,w,h]);
}
module arm4(l,a,w,h,s) {
rotate([0,90+a,0])
linear_extrude(height=l,scale=1-s)
square([h,w],center=true);
}
module arms(w,h,add) {
translate([a1x,0,a1z])
difference() {
  arm(arm1_l,arm1_a,w,h,add);
  translate([-2*h-add/2,-w,-h])
  cube([2*h,2*w,2*h]);
}
translate([a2x,0,a2z])
  arm(arm2_l,arm2_a,w,h,add);
translate([a3x,0,a3z])
  arm(arm3_l,arm3_a,w,h,add);
translate([a2x,0,a2z])
  rotate([90,0,0])
  cylinder(w,r=h/2,center=true,$fn=24);
translate([a3x,0,a3z])
  rotate([90,0,0])
  cylinder(w,r=h/2,center=true,$fn=24);
}
*difference() {
arms(arm_w,arm_h,0);
arms(hole_w,hole_h,mini);
}
//


//  ------------  mount hole

mh_r1=2.2;
mh_r2=4.1;
mh_l=3.2;
mh_y2=30;
mh_y3=20;
mh_z2=0;
mh_z3=9;
mh_z3_0=9;
mh_h3=8;
mh_h4=14;

module mount_hole() {

//for (y=[-1,1])
//for (y=[-1,0,1])
for (y=[0])
translate([0,y*mh_y2,mh_z2])
rotate([0,90,0]) {
translate([0,0,-mini])
  cylinder(mh_l+mini,r=mh_r1,$fn=12);
translate([0,0,mh_l])
  cylinder(mh_r2-mh_r1,mh_r1,mh_r2,$fn=12);
translate([0,0,mh_l+(mh_r2-mh_r1)])
  cylinder(mount_th-mh_l-(mh_r2-mh_r1),r=mh_r2,$fn=12);
}
for (y=[0])
translate([0,y*mh_y3,mh_z3+(y==0 ? mh_z3_0 : 0)])
rotate([0,90,0]) {
translate([0,0,-mini])
  cylinder(mh_l+mini,r=mh_r2,$fn=12);
translate([-mh_h3,-mh_r1,0])
  cube([mh_h3,2*mh_r1,mh_l]);
translate([-mh_h3,0,0])
  cylinder(mh_l,r=mh_r1,$fn=12);
translate([0,0,mh_l])
linear_extrude(height=mh_r2,scale=[1,mini/mh_r2])
translate([-mh_h3-mh_r1-mh_h4,-mh_r2])
  square([mh_r2+mh_h3+mh_r1+mh_h4,2*mh_r2]);
}
}
//mount_hole();


//  ------------  bulb

module bulb() {
hb=43;  //  h1= 57 43  54 ; h2= 28 ;  d1 - 28 ; d2 - 25
translate([0,0,holder_h-holder_h_int])
  cylinder(hb,d=28,$fn=24);
translate([0,0,holder_h-holder_h_int+hb])
  cylinder(28,d=25,$fn=24);
}
//bulb();



