// fourbar.scad

include <Library/BentSim/Bike_accessories.scad>
include <Library/NACAAirfoils/files/Naca4.scad>
include <Library/skew.scad>

module fourbar_leg(length=1000, chord=100, long_skew=30, lat_skew=30) {
    // upper pivot needs a complex trig transformation!
    translate([(length * cos(long_skew) * cos(lat_skew)) - (2 * chord), 
    length * cos(long_skew) * sin(lat_skew), 0])
        rotate([0, 90+long_skew, 0])
        cylinder(h=chord, r=12);
    
    // lower pivot: 
    translate([0-chord, -12, (chord/2) * sin(long_skew) * sin(lat_skew)])
        rotate([0, 90+long_skew, 0])
        cylinder(h=chord, r=12);
    
    // aerofoil section
    skew([0, long_skew, 0, 0, 0, 0])
        rotate([lat_skew, 0, 180])
        airfoil(h=length, L=chord);
}


module fourbar(length=1000, chord=100, long_skew=30, lat_skew=30, shoulder=650) {
    translate([0, 0-(shoulder/2), 0])
        fourbar_leg( length, chord, long_skew, lat_skew);
    
    translate([0, shoulder/2, 0])
        mirror([0, 1, 0])
        fourbar_leg(length, chord, long_skew, lat_skew);
    }

fourbar(600, 100, 30, 30, 650);
