+module OrdinaryRearAperture(rhs,bot, pos){
+ Flip_rhs(rhs) Flip_bot(bot)
+ linextr(-20, 20)
+ mirror([0,1])
+ translate(pos + bumper)
+ children();
+}
+
+module MicroUSB(){
+ Flip_bot(1){
+ rotate([90,0,0])
+ mirror([0,0,1])
+ linextr(-epp2i[0], 60)
+ translate([0.5 * phone_width, 0, 0])
+ rectfromto([-microusb_width/2, epp2i[1] + microusb_below],
+ [+microusb_width/2, epp0[1] + -microusb_above]);
+ }
+}
+
+module OrdinaryRearApertures(){
+ // rear speaker
+ OrdinaryRearAperture(1,1, rearspeaker_pos_bl)
+ rectfromto(-rearspeaker_gap,
+ rearspeaker_size + rearspeaker_gap);
+
+ // finger hole to remove phone
+ if (len(fingerpushhole_dias))
+ OrdinaryRearAperture(1,0, [ fingerpushhole_dias[0]/2 + epp2i[0],
+ phone[1]/2 ])
+ scale(fingerpushhole_dias)
+ circle(r= 0.5 );
+}
+
+module RearCameraAperture(){
+ Flip_rhs(1)
+ mirror([0, 0, 1])
+ linear_extrude(height = 20)
+ mirror([0, 1, 0])
+ translate(bumper)
+ rectfromto(camera_pos_tl, camera_pos_br);
+}
+
+module HingeLidProfile(){
+ hull(){
+ circleat(hppT, hp_r1);
+ circleat(lpp12, lp_r12);
+ polygon([lpp10,
+ lpp13 + [2,0],
+ lpp12,
+ hppT]);
+ }
+}
+
+module HingeBaseProfile(){
+ difference(){
+ hull(){
+ circleat(hppB, hp_r1);
+ circleat(hppE, hp_r1);
+ circleat(epp2o, case_th_bottom);
+ circleat(hppB + [10,0], hp_r1);
+ }
+ polygon([epp5, epp1, epp2i, epp3, bppL]);
+ }
+}
+
+module HingeLeverOuterProfile(){
+ hull(){
+ circleat(hppT, hp_r2);
+ circleat(hppB, hp_r2);
+ }
+}
+
+module HingeLeverInnerProfile(){
+ for (c = [hppT, hppB]) {
+ hull()
+ for (x=[-20,20])
+ for (y=[0, c[1] - hppM[1]])
+ translate([x,y])
+ circleat(c, hp_rn);
+ }
+}
+
+module Flip_hinge(){
+ hinge_origin = [0, -(phone_height - hppB[0]), hppB[1]];
+ translate(hinge_origin)
+ rotate([180,0,0])
+ translate(-hinge_origin)
+ children();
+}
+
+module HingePortion(x0,x1){
+ Flip_rhs() Flip_bot(1)
+ translate([x0,0,0])
+ mirror([1,0,0])
+ rotate([90,0,-90])
+ linear_extrude(height=x1-x0)
+ children(0);
+}
+
+module CatchPortion(width){
+ translate([phone_width/2, 0,0])
+ rotate([90,0,-90])
+ linextr(-width/2, width/2)
+ children(0);
+}
+
+module PropRecess(){
+ // origin is nonstandard
+ hwd345 = 0.5*prop_main_width + prop_side_gap;
+ hwd35 = 0.5*prop_fin_width + prop_side_gap;
+ rotate([90,0,90]){
+ linextr(-hwd345, +hwd345)
+ polygon([ prp1,
+ prp2,
+ prp3,
+ prp4,
+ prp4 + [0,10],
+ prp1 + [0,10],
+ ]);
+ linextr(-hwd35, +hwd35)
+ polygon([ prp1,
+ prp3,
+ prp5,
+ prp5 + [0,10],
+ prp1 + [0,10],
+ ]);
+ }
+}
+
+module SomePropProfile(gamma){
+// prop-internal
+ pip1 = [0,0];
+ pip2 = [ 0.5 * (prop_main_th - prop_end_dia),
+ prop_taper_len ];
+
+ translate(prlp1) {
+ circleat([0,0], prop_end_dia/2);
+ cirecleat(pip2, prop_main_th);
+
+ }
+}
+
+module CasePropRecess(pas) {
+ // destructure entry in prop_angle_specs
+ beta = pas[0];
+ b = prop_lengths [ pas[1] ];
+ p = prop_lid_posns[ pas[2]] ;
+
+ k = hp_k;
+ x = k / (2 * sin(beta/2)) - hppT[0];
+ c = p + x;
+
+ // https://en.wikipedia.org/wiki/Solution_of_triangles#Two_sides_and_non-included_angle_given_(SSA) [25.1.18]
+ // we always want the positive solution because it has a closer to c
+ a = c * cos(beta) + sqrt( b*b - pow(c * sin(beta),2) );
+ q = a - x;
+
+ echo(beta, a, b, c);
+
+ Flip_bot(1)
+ translate([ phone_width/2, -q, epp2o[1]-case_th_bottom ])
+ rotate([0,180,0])
+ PropRecess();
+}
+