OpenFlexure Microscope OpenSCAD docs

sample_clips.scad



module sample_clip(clamp_point, t=2.5, w=6, radius_of_curvature=undef, slope=30)
[Source]
module sample_clip(clamp_point, t=2.5, w=6, radius_of_curvature=undef, slope=30){

    default_roc = clamp_point.z/2 + clamp_point.y*sin(slope) - t/2;
    roc = if_undefined_set_default(radius_of_curvature, default_roc);

    //z distance from the contact point to the centre of the curved part
    z_dist = clamp_point.z - roc - t/2;
    //a is the distance from the contact-point cylinder to the
    //centre of the curved part
    a = sqrt(clamp_point.y^2 + z_dist^2);
    //angle through which we must rotate the join between
    angle = acos((roc + t/2) / a) + atan(z_dist/clamp_point.y);


    difference(){
        union(){
            //anchor to stage
            cylinder(r=w/2,h=t);

            translate_z(roc+t){
                rotate_y(90){
                    difference(){
                        cylinder(r=roc+t,h=w,center=true);
                        cylinder(r=roc,h=999,center=true);
                        translate_z(-99){
                            cube([999,999,999]);
                        }
                        translate_z(-99){
                            rotate(angle){
                                cube([999,999,999]);
                            }
                        }
                    }
                }
            }
            sequential_hull(){
                translate_z(roc+t){
                    rotate_y(90){
                        rotate(angle){
                            translate_y(roc+t/2){
                                cylinder(r=t/2,h=w,center=true);
                            }
                        }
                    }
                }
                translate([0,clamp_point.y,clamp_point.z+t/2]){
                    rotate_y(90){
                        cylinder(r=t/2,h=w,center=true);
                    }
                }
                translate([0,clamp_point.y+t,clamp_point.z+t]){
                    rotate_y(90){
                        cylinder(r=t/2,h=w,center=true);
                    }
                }
            }

        }
        cylinder(r=3/2*1.2,h=999,center=true,$fn=16);
    }
}
module sample_clips_stl()
[Source]
module sample_clips_stl(){
    for(a=[0,180]){
        rotate([0,-90,a]){
            translate([7/2,-10,-7+1]){
                default_sample_clip();
            }
        }
    }
}
module default_sample_clip()
[Source]
module default_sample_clip(){
    sample_clip([0,20,-1], w=7, radius_of_curvature=7);
}