Skip to content

Latest commit

 

History

History
151 lines (135 loc) · 5.47 KB

orientation.md

File metadata and controls

151 lines (135 loc) · 5.47 KB

Orientation

Routines to quickly position panels on the face of a box.


List of Functions

OTop( thickness, offset ) position children as top panel
OBottom( thickness, offset )position children as bottom panel
OFront( thickness, offset ) position children as front panel
OBack( thickness, offset ) position children as back panel
OLeft( thickness, offset ) position children as left panel
ORight( thickness, offset ) position children as right panel
OFTop( thickness, offset ) same as OTop() but flipped
OFBottom( thickness, offset )same as OBottom() but flipped
OFFront( thickness, offset ) same as OFront() but flipped
OFBack( thickness, offset ) same as OBack() but flipped
OFLeft( thickness, offset ) same as OLeft() but flipped
OFRight( thickness, offset ) same as ORight() but flipped

OTop( thickness, offset, leftRight, frontBack, faceIn )

thickness panel thickness
offset = 0 up/down offset, UP+
leftRight = 0 left/right offset, right+
frontBack = 0 front/back offset, back+
faceIn = falsewhether panel is to face inwards or outwards the "box"

OBottom( thickness, offset, leftRight, frontBack, faceIn )

thickness panel thickness
offset = 0 up/down offset, DOWN+
leftRight = 0left/right offset, right+
frontBack = 0front/back offset, back+
faceIn = truewhether panel is to face inwards or outwards the "box"

OFront( thickness, offset, leftRight, upDown, faceIn )

thickness panel thickness
offset = 0 front/back offset, FRONT+
leftRight = 0 left/right offset, right+
upDown = 0 up/down offset, up+
faceIn = falsewhether panel is to face inwards or outwards the "box"

OBack( thickness, offset, leftRight, upDown, faceIn )

thickness panel thickness
offset = 0 front/back offset, BACK+
leftRight = 0left/right offset, right+
upDown = 0 up/down offset, up+
faceIn = truewhether panel is to face inwards or outwards the "box"

OLeft( thickness, offset, frontBack, upDown, faceIn )

thickness panel thickness
offset = 0 left/right offset, LEFT+
frontBack = 0front/back offset, back+
upDown = 0 up/down offset, up+
faceIn = truewhether panel is to face inwards or outwards the "box"

ORight( thickness, offset, frontBack, upDown, faceIn )

thickness panel thickness
offset = 0 left/right offset, RIGHT+
frontBack = 0front/back offset, back+
upDown = 0 up/down offset, up+
faceIn = truewhether panel is to face inwards or outwards the "box"

OF<direction>( thickness, offset, frontBack, upDown, faceIn )

same as similarly named version but faceIn is reversed eg. OTop( faceIn=false ), OFTop( faceIn=true ), ...


Sample Code

photo

// NATURAL POSITIONING
axis();
Panel(50,50);
color("steelblue") OFront (THK,50) Panel(50,50);
color("red")       OBack  (THK,50) Panel(50,50);
color("green")     OLeft  (THK,50) Panel(50,50);
color("violet")    ORight (THK,50) Panel(50,50);
color("orange")    OTop   (THK,50) Panel(50,50);
color("gold")      OBottom(THK,50) Panel(50,50);

// FLIP OF NATURAL
translate( [100,0,0] ) {
    axis();
    Panel(50,50);
    color("steelblue") OFFront (THK,50) Panel(50,50);
    color("red")       OFBack  (THK,50) Panel(50,50);
    color("green")     OFLeft  (THK,50) Panel(50,50);
    color("violet")    OFRight (THK,50) Panel(50,50);
    color("orange")    OFTop   (THK,50) Panel(50,50);
    color("gold")      OFBottom(THK,50) Panel(50,50);
}

W   = 40; // width
D   = 50; // depth
H   = 80; // height
THK =  3; // thickness of panel

// panels facing outwards
translate( [210,0,0] )
    Box( faceIn=false );

// panels facing inwards
translate( [300,0,0] )
    Box( faceIn=true );

module axis() {
    color("red") {
        cube([100,1,1],center=true);
        cube([1,100,1],center=true);
        cube([1,1,100],center=true);
    }
}

module Box( faceIn ) {
    // less: THK*2, so no overlap
    OBottom(THK, H/2, faceIn=faceIn) color("gold"     ) Panel( W,D               );
    OLeft  (THK, W/2, faceIn=faceIn) color("green"    ) Panel(   D-THK*2,H-THK*2 );
    OBack  (THK, D/2, faceIn=faceIn) color("red"      ) Panel( W,        H-THK*2 );
    OTop   (THK, H/2, faceIn=faceIn) color("orange"   ) Panel( W,D               );
    ORight (THK, W/2, faceIn=faceIn) color("violet"   ) Panel(   D-THK*2,H-THK*2 );
    OFront (THK, D/2, faceIn=faceIn) color("steelblue") Panel( W,        H-THK*2 );
    CubeExtents( W,D,H, color="red" );
}

module Panel( width,height ) {
    linear_extrude( THK, center=true )
    difference() {
        square( [width,height], center=true );
        {
            translate( [width*.25,-height*.25,0] )
                square( [width/4,height/4], center=true );
            translate( [-width*.25,-height*.25,0] )
                circle( d=width/4 );
            translate( [0,height*.25,0] )
                text("H3LLO",size=6,halign="center",valign="center");
        }
    }
}