// tricycle.scad: 

include <Library/BentSim/Bike_accessories.scad>

include <Library/SprocketGenerator2/files/Sprocket_Generator_v2_example_10.scad>

module subframe () {
    // front leg (supports cross-shaft, epicyclic, motor
    translate([-25, 1820, -550])
        color("grey")
        cube([50, 25, 230]);
    // bottom bracket leg
    translate([-25, 1690, -578])
        color("grey")
        cube([50, 25, 310]);
    // wheel leg
    translate([-70, 1430, -593])
        rotate([0, 5, 0])
        color("grey")
        cube([25, 75, 363]);
    // front upper
    translate([-25, 2000, -385])
        rotate([70, 0, 0])
        color("grey")
        cube([50, 25, 330]);
    // central upper
    translate([-25, 1700, -275])
        rotate([82, 0, 0])
        color("grey")
        cube([50, 25, 370]);
    // rear leg
    translate([-25, 1200, -515])
        rotate([-23, 0, 0])
        color("grey")
        cube([50, 25, 344]);
    
    // wheel
    translate([0, 1467.5, -450])
        rotate([0, 0, 90])
        // Pierre Rouzeau's wheel is beautifully modelled and parameterised, but it doesn't seem to be scaled as I'd expect...
        scale([0.70, 0.70, 0.70])
        wheel(rim=451, spoke_nbr=0);
        
    // bottom bracket
    translate([-25, 1680, -390])
        color("black")
        rotate([0, 90, 0])
        cylinder(h=68, r=26);
    translate([-35, 1680, -390]) 
        color("silver")
        rotate([0, 90, 0])
        sprocket(teeth=82, roller=7.9, pitch=12.7);
        
     // left crank
     translate([-44, 1680, -395])
        color("black")
        cube([12,20,150]);
        
     // left pedal
     translate([-120, 1670, -265])
        color("black")
        cube([70,40,15]);
        
     // left pedal shaft
     translate([-120, 1690, -257.5])
        color("silver")
        rotate([0,90,0])
        cylinder(h=80,r=4);
        
     // right crank
     translate([44, 1680, -535])
        color("black")
        cube([12,20,150]);
        
     // right pedal
     translate([58, 1670, -525])
        color("black")
        cube([70,40,15]);
        
     // right pedal shaft
     translate([44, 1690, -517.5])
        color("silver")
        rotate([0,90,0])
        cylinder(h=80,r=4);
        
}

subframe();
