Friday, October 26, 2018

Cad Exercises - Doo-ha



Revisiting Cad Exercises

difference(){
    union(){
            translate([0,0,-10])cylinder(80,25,25);
            translate([0,0,-10])cylinder(96,17.5,17.5);
intersection(){
linear_extrude(40,convexity=20){
                    P();
    mirror([0,1,0]) P();
}
translate([40,0,20])rotate([90,0,0])
cylinder(90,70,70,center=true,$fn=60);
}
        }
            translate([0,0,-20])cylinder(120,10,10);
translate([90,0,20])rotate([90,0,0])
cylinder(100,6,6,center=true,$fn=60);

}
module P()
{
 polygon([
        [0,0],[35,0],[35,15],
        [75,15],[75,35],[110,35],
        [110,45],[65,45],[65,25],
        [25,25],[0,25]]);
}
 

Thursday, October 25, 2018

QuackBirdie 2 - All OPENSCAD

By request: QuackBirdie 2 - All OPENSCAD



$Pathdetail=4;
$SphereDetail=20;

union(){ 
$fn = $SphereDetail;

 color("DarkOrange")    DrawSmoothLine(FrillsAndUpperBeak );  
 color("Orange")        DrawSmoothLine(BodyBulk ); 

 color("DarkOrange"){
                        DrawSmoothLine(BeakDetalAndFlank );
               mirror() DrawSmoothLine(BeakDetalAndFlank );
    }
}

//ListOf [X,Y,Z[ScaleX,ScaleY,ScaleZ]]
 
FrillsAndUpperBeak=  [   
 [0, 16, 10, [5, 5, 5]],
 [0, -2, 13, [10, 10, 10]],
 [0, -21, 8, [15, 13, 15]], 
 [0, -10, 28, [5, 5, 5]], 
 [0, -6, 53, [6, 8, 5]],
 [0, -13, 52, [6, 4, 6.5]], 
 [0, -16, 46, [5, 5, 5]], 
 [0, -23.5, 41.5, [11, 5, 4.7]],
 [0, -26.9, 41.9, [9.9, 3, 4]],
 [0, -31.9, 45.3, [5, 3, 2]]

];
BodyBulk= [
[0, 31, 25, [3.5, 3.5, 3.5]],
 [0, 27, 12, [10, 10, 10]],
 [0, 16, 0, [15, 18, 16]],
 [0, 6, 0, [21, 20, 20]],
 [0, -10, 3, [28, 25, 22]],
 [0, -10, 16-1, [9, 9, 12]],
 [0, -10, 30-1, [8, 10, 8]],
 [0, -7, 42-1, [15, 17, 17]], 
[0, -20, 38.5-1, [13, 10, 4]], 
[0, -28, 39-1, [8, 6, 2]]];

 
BeakDetalAndFlank=
[[0, -33, 46.5, [1.5, 2.5, 2.5]], 
[3, -32.5, 46, [1.5, 2.5, 2.5]], 
[6, -30.5, 43, [1.5, 2.5, 2]],
 [7.7, -28, 41.6, [2.5, 2.5, 1.5]],
 [9, -23, 42, [3, 2, 2]], 
[8, -19, 43, [3, 3, 3]], 
[8, -16, 46, [2, 2, 2]],
 [5, -18, 48, [4, 4, 4]], 
[8, -16, 46, [2, 2, 2]],
 [0, -6, 46, [2, 2, 2]], 
[0, -10, 8, [10, 10, 10]], 
[9, -10, 4, [20, 20, 17]], 
[7, 0, 3, [19, 20, 18]], 
[3, 10, 3, [18, 20, 15]]];


module DrawSmoothLine(ListOfPoints)
{
SmoothedLine=SmoothLine (ListOfPoints);
DrawPolyline( SmoothedLine   ) ;
}

function SmoothLine (ListOfPoints)=
let(Steps=(100/$Pathdetail))
[for(t=[0:Steps]) 
(PiecewiseQuadraticBezierCurve(t/Steps, ListOfPoints) )];

function PiecewiseQuadraticBezierCurve
(PositionAlongPath,ListOfPoints)=
let( 
    ListLenght=len(ListOfPoints)-1,        
    PaddedListOfPoints=PadList(ListOfPoints)        ,
    IndexCenterPoint=
round((ListLenght)*PositionAlongPath)+1, // +One to offset padding
    IndexPreviousPoint=IndexCenterPoint-1,
    IndexfollowingPoint=IndexCenterPoint+1,
     
    PositionAlongSegment=(((ListLenght)*PositionAlongPath)+0.5)%1 ,
    
    FirstHandle =
 FindMidpoint
   (PaddedListOfPoints,IndexPreviousPoint,IndexCenterPoint ),
    CenterPoint =
 PaddedListOfPoints[IndexCenterPoint], 
    LastHandle  =
 FindMidpoint
   ( PaddedListOfPoints, IndexCenterPoint,IndexfollowingPoint) ) 

QuadraticBezierSegment 
    (FirstHandle,CenterPoint, LastHandle,PositionAlongSegment ) ;


function PadList(ListOfPoints)=
    concat(ExtendOnePointBefore(ListOfPoints),
            ListOfPoints,
            ExtendOnePointAfter(ListOfPoints) );

function ExtendOnePointBefore(ListOfPoints)=
    [ListOfPoints[0]-(ListOfPoints[1]-ListOfPoints[0])];

function ExtendOnePointAfter(ListOfPoints)=
let( ll=len(ListOfPoints)-1   )
    [ListOfPoints[ll]-(ListOfPoints[ll-1]-ListOfPoints[ll])];

function FindMidpoint(v,ia,ib)=lerp(v[ia],v[ib],0.5);


function lerp( v1, v2, bias) = (1-bias)*v1 + bias*v2;

function QuadraticBezierSegment
        (FirstHandle,CenterPoint, LastHandle,PositionAlongSegment)=
lerp(
    lerp( FirstHandle,CenterPoint,PositionAlongSegment),
    lerp(CenterPoint,LastHandle,PositionAlongSegment),
PositionAlongSegment)
;

module DrawPolyline(PointList ) 
{
for(i=[0:len(PointList)-2])
     DrawLineSegment(PointList[i],PointList[i+1]);
}

module DrawLineSegment(p1, p2 ) 
{
 color(p1[4])   
hull() {
        translate(vec3(p1)) scale(p1[3])sphere(1 );
        translate(vec3(p2)) scale(p2[3])sphere(1);
       }
}


function vec3(v) = [ v.x, v.y, v.z ];

 

 

Tuesday, October 16, 2018

Cad Exercises - Manifold

Revisiting Cad Exercises


 
$fn=80;
color("lightgrey")assembly();

module assembly(){
    difference( ){
        union(){
            bell();
            fftransform()linear_extrude(11) ffprofile ();
            ddtransform() linear_extrude(10)ddprofile();
        }  
    
        union(){
            core();
            fftransform()
linear_extrude(23,center=true, convexity = 20)ffnegprofile();
            ddtransform() 
linear_extrude(23,center=true, convexity = 20)ddnegprofile();
        } 
    }
}
module fftransform(){
        translate([0,0,35])
            rotate([0,-21,0])
                translate([0,0,-20])
                    rotate([0,90,0]) 
                        children() ;}
module ddtransform(){
        rotate([0,0,180+45])
            translate([0,0,35])
                rotate([0,-21,0])
                    translate([0,0,-20])
                        rotate([0,90,0]) 
                            children() ;}
module bell(){ 
    rotate_extrude( ) offset(-0.1)offset(0.2)offset(-0.1)
polygon(
    [
        [27.5,0],[27.5,4],[20,4],
        [9.5,31],[7.5,31],[7.5,35],
        [0,35], [0, 0.0]
    ]); }
module core(){
        rotate_extrude()polygon(
    [
        [0,36],[5.5,36], [5.5,29],   
        [8.13, 29], [19.31, 0.0],[0,-1]
    ]);  
    }
module ffprofile ()
    { 
        offset(-4)offset(4){circle(8);
        translate(  [0,10,0])circle(3.25);
        translate(  [0,-10,0])circle(3.25);}
    }
module ffnegprofile ()
    {  
        circle(14/2);
        translate(  [0,10,0])circle(1.25);
        translate(  [0,-10,0])circle(1.25); 
    } 


module ddprofile ()
    {circle(20/2);}

module ddnegprofile ()
    {  
        circle(12/2);
        translate(  [0,8,0])circle(1.25);
        translate(  [0,-8,0])circle(1.25); 
        translate(  [8,0,0])circle(1.25);
        translate(  [-8,0,0])circle(1.25); 
    }