add the cutout

add the cutout

use <../../../basics/rounded-edges/doughnuts/doughnuts.scad>;

use <../../../shapes/geometry/arc/extruded/extruded-arc.scad>;

module halfCirclePhoneStand(height = 19.125,
                            minkowskiSphereRadius = 0.5,
                            arcRadius = 36,
                            arcRadiusExtension = 1.5)
{
    halfCirclePhoneStand_cradle(height = height,
                                minkowskiSphereRadius = minkowskiSphereRadius,
                                radius = arcRadius,
                                radiusExtension = arcRadiusExtension);

    halfCirclePhoneStand_stand(height = height,
                               minkowskiSphereRadius = minkowskiSphereRadius);
}

// sub-modules and functions follow

module halfCirclePhoneStand_cradle(height,
                                   minkowskiSphereRadius,
                                   radius,
                                   radiusExtension)
{
    difference()
    {
        halfCirclePhoneStand_cradle_bed(height = height,
                                           minkowskiSphereRadius = minkowskiSphereRadius,
                                           radius = radius,
                                           radiusExtension = radiusExtension);

        halfCirclePhoneStand_cradle_cutout(bedHeight = height,
                                        minkowskiSphereRadius = minkowskiSphereRadius,
                                        radius = radius,
                                        radiusExtension = radiusExtension);
    }
}

module halfCirclePhoneStand_cradle_bed(height,
                                       minkowskiSphereRadius,
                                       radius,
                                       radiusExtension)
{
    xTranslate = 30;
    yTranslate = 32.7;
    zTranslate = minkowskiSphereRadius;
    color("magenta")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 213])
    roundedRectangularArc(angle = 150,
                          height = height,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_cradle_cutout(bedHeight,
                                          minkowskiSphereRadius,
                                          radius,
                                          radiusExtension)
{
    zLength = 4.2;

    xTranslate = 30;
    yTranslate = 32.7;
    zTranslate = minkowskiSphereRadius + (bedHeight / 2.0) - (zLength / 2.0);
    color("magenta")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 227])
    roundedRectangularArc(angle = 37,
                          height = zLength,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_stand(height,
                                  minkowskiSphereRadius)
{
    halfCirclePhoneStand_stand_top(height = height,
                                   minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_stand_base(height = height,
                                    minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_base(height,
                                       minkowskiSphereRadius)
{
    color("green")
    translate([0, 0, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 4.9,      // 4.9
                outerRadius = 5.59,     // 5.59
                minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_top(height,
                                      minkowskiSphereRadius)
{
    xTranslate = 8.105;  // 8.05     // 8.1
    yTranslate = 8.85;  // 8.85     // 8.9

    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 1.9,  // 2.0
                outerRadius = 2.6,  // 2.6
                minkowskiSphereRadius = minkowskiSphereRadius);
}

use <../../../basics/rounded-edges/doughnuts/doughnuts.scad>;

use <../../../shapes/geometry/arc/extruded/extruded-arc.scad>;

module halfCirclePhoneStand(height = 19.125,
                            minkowskiSphereRadius = 0.5,
                            arcRadius = 36,
                            arcRadiusExtension = 1.5)
{
    halfCirclePhoneStand_cradle(height = height,
                                minkowskiSphereRadius = minkowskiSphereRadius,
                                radius = arcRadius,
                                radiusExtension = arcRadiusExtension);

    halfCirclePhoneStand_stand(height = height,
                               minkowskiSphereRadius = minkowskiSphereRadius);
}

// sub-modules and functions follow

module halfCirclePhoneStand_cradle(height,
                                   minkowskiSphereRadius,
                                   radius,
                                   radiusExtension)
{
    halfCirclePhoneStand_cradle_bed(height = height,
                                       minkowskiSphereRadius = minkowskiSphereRadius,
                                       radius = radius,
                                       radiusExtension = radiusExtension);

    halfCirclePhoneStand_cradle_cutout(height = height,
                                       minkowskiSphereRadius = minkowskiSphereRadius,
                                       radius = radius,
                                       radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_cradle_bed(height,
                                       minkowskiSphereRadius,
                                       radius,
                                       radiusExtension)
{
    xTranslate = 30;      // 29.9
    yTranslate = 32.7;      // 32.6
    zTranslate = minkowskiSphereRadius + 0;     // 0.13;
    color("magenta")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 213])     // 212
    roundedRectangularArc(angle = 150,
                          height = height,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_cradle_cutout(height,
                                   minkowskiSphereRadius,
                                   radius,
                                   radiusExtension)
{
    zLength = 5;

    zTranslate = minkowskiSphereRadius + (height / 2.0) - (zLength / 2.0);

}

module halfCirclePhoneStand_stand(height,
                                  minkowskiSphereRadius)
{
    halfCirclePhoneStand_stand_top(height = height,
                                   minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_stand_base(height = height,
                                    minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_base(height,
                                       minkowskiSphereRadius)
{
    color("green")
    translate([0, 0, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 4.9,      // 4.9
                outerRadius = 5.59,     // 5.59
                minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_top(height,
                                      minkowskiSphereRadius)
{
    xTranslate = 8.105;  // 8.05     // 8.1
    yTranslate = 8.85;  // 8.85     // 8.9

    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 1.9,  // 2.0
                outerRadius = 2.6,  // 2.6
                minkowskiSphereRadius = minkowskiSphereRadius);
}


change the default x,y location of the bases

use <../../../basics/rounded-edges/doughnuts/doughnuts.scad>;

use <../../../basics/rounded-edges/rounded-pyramid/rounded-pyramid.scad>;

use <../../../shapes/geometry/arc/extruded/extruded-arc.scad>;

use <../../../external-resources/aquaman/aquaman-logo.scad>
use <../../../external-resources/cat/cat.scad>
use <../../../external-resources/music/notes/bass-clef/bass-clef.scad>
use <../../../external-resources/music/notes/treble-clef/treble-clef-scaled-down.scad>
use <../../../external-resources/plumber-brother/l/luigi-outline.scad>
use <../../../external-resources/plumber-brother/m/mario.scad>
use <../../../external-resources/rebel-alliance/rebel-alliance.scad>
use <../../../external-resources/thundercats/thundercats-logo.scad>
use <../../../external-resources/trooper/scrum-trooper.scad>
use <../../../shapes/crescent-moon/crescent-moon.scad>
use <../../../shapes/fan/iso-7000-fan.scad>
use <../../../shapes/fish/fish.scad>
use <../../../shapes/heart/heart.scad>
use <../../../shapes/light-bulb/light-bulb.scad>
use <../../../shapes/minecraft/creeper/creeper-face.scad>
use <../../../shapes/spurs/spurs-a.scad>
use <../../../shapes/weather/sun/sun.scad>

module halfCirclePhoneStand(base_xTranslate = -1.0,
                            base_yTranslate = -1.0,

                            bed_cutout_zLength = 4.2,
                            height = 19.125,

                            iconColor = "red",
                            iconType = "None",
                            iconXyScale = 1.0,
                            iconHeight = 3.0,
                            icon_xOffset = 5,
                            icon_yOffset = 5,
                            icon_zOffset = 5,

                            minkowskiSphereRadius = 0.5,
                            arcRadius = 36,
                            arcRadiusExtension = 1.5,

                            stand_top_xTranslate = 9.105,
                            stand_top_yTranslate = 9.85,
                            stand_connectorBar_xLength = 5)
{
    halfCirclePhoneStand_cradle(height = height,

                                bed_cutout_zLength = bed_cutout_zLength,

                                iconColor = iconColor,
                                iconType = iconType,
                                iconXyScale = iconXyScale,
                                iconHeight = iconHeight,
                                icon_xOffset = icon_xOffset,
                                icon_yOffset = icon_yOffset,
                                icon_zOffset = icon_zOffset,

                                minkowskiSphereRadius = minkowskiSphereRadius,
                                radius = arcRadius,
                                radiusExtension = arcRadiusExtension);

    halfCirclePhoneStand_stand(base_xTranslate = base_xTranslate,
                               base_yTranslate = base_yTranslate,
                               bed_cutout_zLength = bed_cutout_zLength,
                               height = height,
                               minkowskiSphereRadius = minkowskiSphereRadius,
                               stand_connectorBar_xLength = stand_connectorBar_xLength,
                               stand_top_xTranslate = stand_top_xTranslate,
                               stand_top_yTranslate = stand_top_yTranslate);
}

// sub-modules and functions follow

function halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius,
                                                        bedHeight,
                                                        zLength) = minkowskiSphereRadius + (bedHeight / 2.0) - (zLength / 2.0);

module halfCirclePhoneStand_cradle(height,

                                   bed_cutout_zLength,

                                   iconColor, iconType, iconXyScale, iconHeight,
                                   icon_xOffset, icon_yOffset, icon_zOffset,

                                   minkowskiSphereRadius,
                                   radius,
                                   radiusExtension)
{
    xTranslate = 30;
    yTranslate = 32.7;

    difference()
    {
        halfCirclePhoneStand_cradle_bed(height = height,
                                           minkowskiSphereRadius = minkowskiSphereRadius,
                                           radius = radius,
                                           radiusExtension = radiusExtension,
                                           xTranslate = xTranslate,
                                           yTranslate = yTranslate);

        halfCirclePhoneStand_cradle_cutout(bedHeight = height,
                                        minkowskiSphereRadius = minkowskiSphereRadius,
                                        radius = radius,
                                        radiusExtension = radiusExtension,
                                        bed_xTranslate = xTranslate,
                                        bed_yTranslate = yTranslate,
                                        bed_cutout_zLength = bed_cutout_zLength);
    }

    halfCirclePhoneStand_cradle_icon(iconColor = iconColor,
                                     iconType = iconType,
                                     iconXyScale = iconXyScale,
                                     iconHeight = iconHeight,
                                     xOffset = icon_xOffset,
                                     yOffset = icon_yOffset,
                                     zOffset = icon_zOffset);

    halfCirclePhoneStand_cradle_ends(height = height,
                                     minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_bed(height,
                                       minkowskiSphereRadius,
                                       radius,
                                       radiusExtension,
                                       xTranslate,
                                       yTranslate)
{
    zTranslate = minkowskiSphereRadius;
    color("magenta")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 213])
    roundedRectangularArc(angle = 150,
                          height = height,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_cradle_cutout(bedHeight,
                                          minkowskiSphereRadius,
                                          radius,
                                          radiusExtension,
                                          bed_xTranslate,
                                          bed_yTranslate,
                                          bed_cutout_zLength)
{
    zLength = bed_cutout_zLength;

    cutoutRadiusExtension = radiusExtension + 3;

    xTranslate = bed_xTranslate + 0.2;
    yTranslate = bed_yTranslate + 0.2;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength);

    color("DarkTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 227])
    roundedRectangularArc(angle = 37,
                          height = zLength,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = cutoutRadiusExtension);
}

module halfCirclePhoneStand_cradle_ends(height,
                                        minkowskiSphereRadius)
{
    halfCirclePhoneStand_cradle_ends_top(height = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_cradle_ends_bottom(height = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_bottom(height,
                                               minkowskiSphereRadius)
{
    xTranslate = 2.8;
    yTranslate = 56.35;
    zTranslate = minkowskiSphereRadius;

    // bottom end
    color("PaleTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    halfCirclePhoneStand_cradle_ends_cylinder(height = height,
                                              minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_top(height,
                                        minkowskiSphereRadius)
{
    xTranslate = 40.3;
    yTranslate = -2.5;
    zTranslate = minkowskiSphereRadius;

    // bottom end
    color("PaleTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    halfCirclePhoneStand_cradle_ends_cylinder(height = height,
                                              minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_cylinder(height,
                                        minkowskiSphereRadius)
{
    roundedPyramid(h = height,
                   cornerRadius = minkowskiSphereRadius,
                   cylinderFn = 20,
                   r1 = 2.57,
                   r2 = 2.57,
                   sides = 30);
}

module halfCirclePhoneStand_cradle_icon(iconColor, iconType, iconXyScale, iconHeight, xOffset, yOffset, zOffset)
{
//echo("xOffset", xOffset);

    color(iconColor)

    translate([xOffset, yOffset, zOffset])
    rotate([0, 90, 0])
    scale([iconXyScale, iconXyScale, iconHeight])
    if(iconType == "Aqua Dude")
    {
        aquamanThumbnail(height=2.19);
    }
    else if(iconType == "Bass Clef")
    {
    	bassClefThumbnail(height = 2.7);
    }
    else if(iconType == "Cat")
    {
        catThumbnail(height = 2, xyScale = 0.37);
    }
    else if(iconType == "Creeper")
    {
        creeperFaceThumbnail(height = 1.7);
    }
    else if(iconType == "Fan")
    {
        scale([1, 1, 2.1])
        fanThumbnail();
    }
    else if(iconType == "Fish")
    {
        scale([1, 1, 1.6])
        fishThumbnail();
    }
    else if(iconType == "Heart")
    {
        scale([1, 1, 1.9])
        heartThumbnail();
    }
    else if(iconType == "Light Bulb")
    {
        lightBulbThumbnail();
    }
    else if(iconType == "Mario")
    {
        marioThumbnail();
    }
    else if(iconType == "Luigi")
    {
        luigiThumbnail();
    }
    else if(iconType == "Moon")
    {
        crescentMoonThumbnail();
    }
    else if(iconType == "Rebel")
    {
        rebelAllianceThumbnail(height = 1.7);
    }
    else if(iconType == "Spur")
    {
        spurThumbnail();
    }
    else if(iconType == "Sun")
    {
        sunThumbnail(height = 1.6);
    }
    else if(iconType == "Trooper")
    {
        scrumTrooperThumbnail(height = 2);
    }
    else if(iconType == "Thundercat")
    {
        thundercatsLogoThumbnail(height = 1.7);
    }
    else if(iconType == "Treble Clef")
    {
        trebleClefScaledDownThumbnail(h=2);
    }
    else
    {
        echo("drawing no icon");
    }
}

module halfCirclePhoneStand_stand(base_xTranslate,
                                  base_yTranslate,
                                  bed_cutout_zLength,
                                  height,
                                  minkowskiSphereRadius,
                                  stand_connectorBar_xLength,
                                  stand_top_xTranslate,
                                  stand_top_yTranslate)
{
    halfCirclePhoneStand_stand_top(height = height,
                                   minkowskiSphereRadius = minkowskiSphereRadius,
                                   xTranslate = stand_top_xTranslate,
                                   yTranslate = stand_top_yTranslate);

    halfCirclePhoneStand_stand_connectorBar(bed_cutout_zLength = bed_cutout_zLength,
                                            bedHeight = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius,
                                            xLength = stand_connectorBar_xLength);

    halfCirclePhoneStand_stand_base(height = height,
                                    minkowskiSphereRadius = minkowskiSphereRadius,
                                    xTranslate = base_xTranslate,
                                    yTranslate = base_yTranslate);
}

module halfCirclePhoneStand_stand_base(height,
                                       minkowskiSphereRadius,
                                       xTranslate,
                                       yTranslate)
{
    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 4.9,      // 4.9
                outerRadius = 5.59,     // 5.59
                minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_connectorBar(bed_cutout_zLength, minkowskiSphereRadius, bedHeight, xLength)
{
    yLength = 3;
    zLength = bed_cutout_zLength + minkowskiSphereRadius;

    xTranslate = 5;
    yTranslate = 5;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength)
                    + (zLength / 2.0);

    color("blue")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 45])
    cube([xLength, yLength, zLength], center = true);
}

module halfCirclePhoneStand_stand_top(height,
                                      minkowskiSphereRadius,
                                      xTranslate,
                                      yTranslate)
{
    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 1.9,
                outerRadius = 2.6,
                minkowskiSphereRadius = minkowskiSphereRadius);
}

use <../../../basics/rounded-edges/doughnuts/doughnuts.scad>;

use <../../../basics/rounded-edges/rounded-pyramid/rounded-pyramid.scad>;

use <../../../shapes/geometry/arc/extruded/extruded-arc.scad>;

use <../../../external-resources/aquaman/aquaman-logo.scad>
use <../../../external-resources/cat/cat.scad>
use <../../../external-resources/music/notes/bass-clef/bass-clef.scad>
use <../../../external-resources/music/notes/treble-clef/treble-clef-scaled-down.scad>
use <../../../external-resources/plumber-brother/l/luigi-outline.scad>
use <../../../external-resources/plumber-brother/m/mario.scad>
use <../../../external-resources/rebel-alliance/rebel-alliance.scad>
use <../../../external-resources/thundercats/thundercats-logo.scad>
use <../../../external-resources/trooper/scrum-trooper.scad>
use <../../../shapes/crescent-moon/crescent-moon.scad>
use <../../../shapes/fan/iso-7000-fan.scad>
use <../../../shapes/fish/fish.scad>
use <../../../shapes/heart/heart.scad>
use <../../../shapes/light-bulb/light-bulb.scad>
use <../../../shapes/minecraft/creeper/creeper-face.scad>
use <../../../shapes/spurs/spurs-a.scad>
use <../../../shapes/weather/sun/sun.scad>

module halfCirclePhoneStand(base_xTranslate = 0,
                            base_yTranslate = 0,

                            bed_cutout_zLength = 4.2,
                            height = 19.125,

                            iconColor = "red",
                            iconType = "None",
                            iconXyScale = 1.0,
                            iconHeight = 3.0,
                            icon_xOffset = 5,
                            icon_yOffset = 5,
                            icon_zOffset = 5,

                            minkowskiSphereRadius = 0.5,
                            arcRadius = 36,
                            arcRadiusExtension = 1.5,

                            stand_top_xTranslate = 8.105,
                            stand_top_yTranslate = 8.85,
                            stand_connectorBar_xLength = 5)
{
    halfCirclePhoneStand_cradle(height = height,

                                bed_cutout_zLength = bed_cutout_zLength,

                                iconColor = iconColor,
                                iconType = iconType,
                                iconXyScale = iconXyScale,
                                iconHeight = iconHeight,
                                icon_xOffset = icon_xOffset,
                                icon_yOffset = icon_yOffset,
                                icon_zOffset = icon_zOffset,

                                minkowskiSphereRadius = minkowskiSphereRadius,
                                radius = arcRadius,
                                radiusExtension = arcRadiusExtension);

    halfCirclePhoneStand_stand(base_xTranslate = base_xTranslate,
                               base_yTranslate = base_yTranslate,
                               bed_cutout_zLength = bed_cutout_zLength,
                               height = height,
                               minkowskiSphereRadius = minkowskiSphereRadius,
                               stand_connectorBar_xLength = stand_connectorBar_xLength,
                               stand_top_xTranslate = stand_top_xTranslate,
                               stand_top_yTranslate = stand_top_yTranslate);
}

// sub-modules and functions follow

function halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius,
                                                        bedHeight,
                                                        zLength) = minkowskiSphereRadius + (bedHeight / 2.0) - (zLength / 2.0);

module halfCirclePhoneStand_cradle(height,

                                   bed_cutout_zLength,

                                   iconColor, iconType, iconXyScale, iconHeight,
                                   icon_xOffset, icon_yOffset, icon_zOffset,

                                   minkowskiSphereRadius,
                                   radius,
                                   radiusExtension)
{
    xTranslate = 30;
    yTranslate = 32.7;

    difference()
    {
        halfCirclePhoneStand_cradle_bed(height = height,
                                           minkowskiSphereRadius = minkowskiSphereRadius,
                                           radius = radius,
                                           radiusExtension = radiusExtension,
                                           xTranslate = xTranslate,
                                           yTranslate = yTranslate);

        halfCirclePhoneStand_cradle_cutout(bedHeight = height,
                                        minkowskiSphereRadius = minkowskiSphereRadius,
                                        radius = radius,
                                        radiusExtension = radiusExtension,
                                        bed_xTranslate = xTranslate,
                                        bed_yTranslate = yTranslate,
                                        bed_cutout_zLength = bed_cutout_zLength);
    }

    halfCirclePhoneStand_cradle_icon(iconColor = iconColor,
                                     iconType = iconType,
                                     iconXyScale = iconXyScale,
                                     iconHeight = iconHeight,
                                     xOffset = icon_xOffset,
                                     yOffset = icon_yOffset,
                                     zOffset = icon_zOffset);

    halfCirclePhoneStand_cradle_ends(height = height,
                                     minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_bed(height,
                                       minkowskiSphereRadius,
                                       radius,
                                       radiusExtension,
                                       xTranslate,
                                       yTranslate)
{
    zTranslate = minkowskiSphereRadius;
    color("magenta")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 213])
    roundedRectangularArc(angle = 150,
                          height = height,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = radiusExtension);
}

module halfCirclePhoneStand_cradle_cutout(bedHeight,
                                          minkowskiSphereRadius,
                                          radius,
                                          radiusExtension,
                                          bed_xTranslate,
                                          bed_yTranslate,
                                          bed_cutout_zLength)
{
    zLength = bed_cutout_zLength;

    cutoutRadiusExtension = radiusExtension + 3;

    xTranslate = bed_xTranslate + 0.2;
    yTranslate = bed_yTranslate + 0.2;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength);

    color("DarkTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 227])
    roundedRectangularArc(angle = 37,
                          height = zLength,
                          minkowskiRadius = minkowskiSphereRadius,
                          radius = radius,
                          radiusExtension = cutoutRadiusExtension);
}

module halfCirclePhoneStand_cradle_ends(height,
                                        minkowskiSphereRadius)
{
    halfCirclePhoneStand_cradle_ends_top(height = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);

    halfCirclePhoneStand_cradle_ends_bottom(height = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_bottom(height,
                                               minkowskiSphereRadius)
{
    xTranslate = 2.8;
    yTranslate = 56.35;
    zTranslate = minkowskiSphereRadius;

    // bottom end
    color("PaleTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    halfCirclePhoneStand_cradle_ends_cylinder(height = height,
                                              minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_top(height,
                                        minkowskiSphereRadius)
{
    xTranslate = 40.3;
    yTranslate = -2.5;
    zTranslate = minkowskiSphereRadius;

    // bottom end
    color("PaleTurquoise")
    translate([xTranslate, yTranslate, zTranslate])
    halfCirclePhoneStand_cradle_ends_cylinder(height = height,
                                              minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_cradle_ends_cylinder(height,
                                        minkowskiSphereRadius)
{
    roundedPyramid(h = height,
                   cornerRadius = minkowskiSphereRadius,
                   cylinderFn = 20,
                   r1 = 2.57,
                   r2 = 2.57,
                   sides = 30);
}

module halfCirclePhoneStand_cradle_icon(iconColor, iconType, iconXyScale, iconHeight, xOffset, yOffset, zOffset)
{
//echo("xOffset", xOffset);

    color(iconColor)

    translate([xOffset, yOffset, zOffset])
    rotate([0, 90, 0])
    scale([iconXyScale, iconXyScale, iconHeight])
    if(iconType == "Aqua Dude")
    {
        aquamanThumbnail(height=2.19);
    }
    else if(iconType == "Bass Clef")
    {
    	bassClefThumbnail(height = 2.7);
    }
    else if(iconType == "Cat")
    {
        catThumbnail(height = 2, xyScale = 0.37);
    }
    else if(iconType == "Creeper")
    {
        creeperFaceThumbnail(height = 1.7);
    }
    else if(iconType == "Fan")
    {
        scale([1, 1, 2.1])
        fanThumbnail();
    }
    else if(iconType == "Fish")
    {
        scale([1, 1, 1.6])
        fishThumbnail();
    }
    else if(iconType == "Heart")
    {
        scale([1, 1, 1.9])
        heartThumbnail();
    }
    else if(iconType == "Light Bulb")
    {
        lightBulbThumbnail();
    }
    else if(iconType == "Mario")
    {
        marioThumbnail();
    }
    else if(iconType == "Luigi")
    {
        luigiThumbnail();
    }
    else if(iconType == "Moon")
    {
        crescentMoonThumbnail();
    }
    else if(iconType == "Rebel")
    {
        rebelAllianceThumbnail(height = 1.7);
    }
    else if(iconType == "Spur")
    {
        spurThumbnail();
    }
    else if(iconType == "Sun")
    {
        sunThumbnail(height = 1.6);
    }
    else if(iconType == "Trooper")
    {
        scrumTrooperThumbnail(height = 2);
    }
    else if(iconType == "Thundercat")
    {
        thundercatsLogoThumbnail(height = 1.7);
    }
    else if(iconType == "Treble Clef")
    {
        trebleClefScaledDownThumbnail(h=2);
    }
    else
    {
        echo("drawing no icon");
    }
}

module halfCirclePhoneStand_stand(base_xTranslate,
                                  base_yTranslate,
                                  bed_cutout_zLength,
                                  height,
                                  minkowskiSphereRadius,
                                  stand_connectorBar_xLength,
                                  stand_top_xTranslate,
                                  stand_top_yTranslate)
{
    halfCirclePhoneStand_stand_top(height = height,
                                   minkowskiSphereRadius = minkowskiSphereRadius,
                                   xTranslate = stand_top_xTranslate,
                                   yTranslate = stand_top_yTranslate);

    halfCirclePhoneStand_stand_connectorBar(bed_cutout_zLength = bed_cutout_zLength,
                                            bedHeight = height,
                                            minkowskiSphereRadius = minkowskiSphereRadius,
                                            xLength = stand_connectorBar_xLength);

    halfCirclePhoneStand_stand_base(height = height,
                                    minkowskiSphereRadius = minkowskiSphereRadius,
                                    xTranslate = base_xTranslate,
                                    yTranslate = base_yTranslate);
}

module halfCirclePhoneStand_stand_base(height,
                                       minkowskiSphereRadius,
                                       xTranslate,
                                       yTranslate)
{
    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 4.9,      // 4.9
                outerRadius = 5.59,     // 5.59
                minkowskiSphereRadius = minkowskiSphereRadius);
}

module halfCirclePhoneStand_stand_connectorBar(bed_cutout_zLength, minkowskiSphereRadius, bedHeight, xLength)
{
    yLength = 3;
    zLength = bed_cutout_zLength + minkowskiSphereRadius;

    xTranslate = 5;
    yTranslate = 5;
    zTranslate = halfCirclePhoneStand_cradle_cutout_zTranslate(minkowskiSphereRadius = minkowskiSphereRadius,
                                                                bedHeight = bedHeight,
                                                                zLength = zLength)
                    + (zLength / 2.0);

    color("blue")
    translate([xTranslate, yTranslate, zTranslate])
    rotate([0, 0, 45])
    cube([xLength, yLength, zLength], center = true);
}

module halfCirclePhoneStand_stand_top(height,
                                      minkowskiSphereRadius,
                                      xTranslate,
                                      yTranslate)
{
    color("green")
    translate([xTranslate, yTranslate, minkowskiSphereRadius])
    roundDoughnut(height = height,
                innerRadius = 1.9,
                outerRadius = 2.6,
                minkowskiSphereRadius = minkowskiSphereRadius);
}


Rotated plate for easy printing without rotating in printing software.  Added 'Power' text.

$fn = 20;

width = 60.4;
length = 162.2;
thickness = 3;

screenWidth = 50.9;
screenLength = 70.6;

screwD = 2.9;

frameStandoffHorzSep = 48.6;
frameStandoffVert = [-68.5, -15.2, 75];

pcbStandoff = [[12.7, 0],
			  [-12.7, 0],
               [12.7, 80],
			  [-12.7, 80]];

pcbStandoffY = -12;

rotate([0,180,0]) {
    difference(){
        translate([0, 0, 1.5])
        hull(){
            roundedCube([width, length, thickness], 4);
            translate([0, 0, 0.5])
            roundedCube([width-4, length-4, thickness+1], 2);
        }

        translate([0, 28.5, 2.5])
        cube([screenWidth, screenLength, 6], center = true);

        for (i = frameStandoffVert){
            for (j = [-1, 1]){
                translate([j*frameStandoffHorzSep/2, i, 0])
                cylinder(r = screwD/2, h = 3);
            }
        }

        translate([-8, -11, thickness - 2.1])
        scale([1, 1, 5])
        text("POWER", 3);
    }

    for (i = frameStandoffVert){
        for (j = [-1, 1]){
            translate([j*frameStandoffHorzSep/2, i, 0])
            standoff(6, 5);
        }
    }

    translate([0, pcbStandoffY, 0])
    for (i = pcbStandoff){
        translate(i)
        standoff(6, 14.6);
    }
}

module standoff(diameter, height){
	translate([0, 0, -height])
	difference(){
		cylinder(r = diameter/2, h = height);
        translate([0, 0, -0.1])
		cylinder(r = screwD/2, h = height + 0.1);
	}
}

module roundedCube(size, radius) {
  cube(size - [2*radius,0,0], true);
  cube(size - [0,2*radius,0], true);
  for (x = [radius-size[0]/2, -radius+size[0]/2],
       y = [radius-size[1]/2, -radius+size[1]/2]) {
    translate([x,y,0]) cylinder(r=radius, h=size[2], center=true);
  }
}

$fn = 20;

width = 60.4;
length = 162.2;

screenWidth = 50.9;
screenLength = 70.6;

screwD = 2.9;

frameStandoffHorzSep = 48.6;
frameStandoffVert = [-68.5, -15.2, 75];

pcbStandoff = [[12.7, 0],
			  [-12.7, 0],
               [12.7, 80],
			  [-12.7, 80]];

pcbStandoffY = -12;

difference(){
	translate([0, 0, 1.5])
	hull(){
		roundedCube([width, length, 3], 4);
		translate([0, 0, 0.5])
		roundedCube([width-4, length-4, 4], 2);
	}

	translate([0, 28.5, 2.5])
	cube([screenWidth, screenLength, 5], center = true);

	for (i = frameStandoffVert){
		for (j = [-1, 1]){
			translate([j*frameStandoffHorzSep/2, i, 0])
			cylinder(r = screwD/2, h = 3);
		}
	}
}

for (i = frameStandoffVert){
	for (j = [-1, 1]){
		translate([j*frameStandoffHorzSep/2, i, 0])
		standoff(6, 5);
	}
}

translate([0, pcbStandoffY, 0])
for (i = pcbStandoff){
	translate(i)
	standoff(6, 14.6);
}

module standoff(diameter, height){
	translate([0, 0, -height])
	difference(){
		cylinder(r = diameter/2, h = height);
		cylinder(r = screwD/2, h = height);
	}
}

module roundedCube(size, radius) {
  cube(size - [2*radius,0,0], true);
  cube(size - [0,2*radius,0], true);
  for (x = [radius-size[0]/2, -radius+size[0]/2],
       y = [radius-size[1]/2, -radius+size[1]/2]) {
    translate([x,y,0]) cylinder(r=radius, h=size[2], center=true);
  }
}


added hole for LCD insertion (no drills yet, though)

use <lcd.scad>
use <menu_knob.scad>
use <menu_knob_manipulator.scad>
use <reset_button.scad>
use <sdcard_reader.scad>
use <cable_guide.scad>

boxSize = [143, 148, 6+7];
lcdOffset = boxSize - [98+5, 60+5, 12];
encoderOffset = [20-14/2, boxSize[1]-30/2-15/2-3, boxSize[2]-(6+7)];
sdCardOffset = [35, 80, boxSize[2]-6];
resetButtonOffset = [encoderOffset[0]+14/2, 68, 1];

//rotate([180, 0, 0])
{
  difference()
  {
    union()
    {
      // main mounting legs
      for(offset = [ [boxSize[0]-16, 0, boxSize[2]-7], [boxSize[0]-70, 0, boxSize[2]-7] ])
        translate(offset)
          cube([16, 40+13, 7]);
      // side mounting wing
      translate([15, 0, 6])
        cube([18, 20, 7]);

      difference()
      {
        // main working area
        cube(boxSize);
        // prusa's framework  corner
        translate([15, 0, 0])
          cube([143-15, 53, boxSize[2]]);
        // LCD
        translate(lcdOffset)
        {
          // LCD itself
          translate([1/2-2/2, 10-1, 2])
            cube([97+2, 40+2, 10]);
          // place for PCB
          translate([-2/2, -1/2, -lcdOffset[2]-7])
            cube([98+2, 60+1, 10]);
          // place for cables
          translate([9, 60-5, -2])
            cube([39,10,4]);
          lcdBoard();
        }
        // encoder
        translate(encoderOffset)
        {
          translate([-2, -1/2, -8])
            cube([14+2*2, 12+1, 8+6]);
          menuKnob();
        }
        // SD card mount
        translate(sdCardOffset)
          rotate([0,180,0])
            sdCardReader();
        // reset button
        translate(resetButtonOffset)
        {
          translate([0, 0, -resetButtonOffset[2]])
            cylinder(r=(16+1)/2, h=boxSize[2])
          resetButton();
        }
        // cable guide drill
        translate([boxSize[0]-98-5, 40+16+6, 0])
          cableGuide();
        // side mounting wing cut-in, so that screw will hold tight
        cube([15, 40, 6]);
      }
    }

    // mounting drills
    for(offsetOY = [ 13/2+5/2, 40+13+5])
      for(offsetOX = [15/2, boxSize[0]-70+16/2, boxSize[0]-16/2])
        translate([offsetOX, offsetOY, -1])
          cylinder(r=5/2, h=6+7+2, $fs=1);
  }

  // LCD stub
  %translate(lcdOffset)
    lcdBoard();
  // encoder stub
  %translate(encoderOffset)
  {
    menuKnob();
    translate([7, 6, 23+4])
      rotate([180,0,0])
        menuKnobManipulator();
  }
  // SD card mount stub
  %translate(sdCardOffset)
    rotate([0,180,0])
      sdCardReader();
  // reset button stub
  %translate(resetButtonOffset)
    resetButton();
}

use <lcd.scad>
use <menu_knob.scad>
use <menu_knob_manipulator.scad>
use <reset_button.scad>
use <sdcard_reader.scad>
use <cable_guide.scad>

boxSize = [143, 148, 6+7];
lcdOffset = boxSize - [98+5, 60+5, 12];
encoderOffset = [20-14/2, boxSize[1]-30/2-15/2-3, boxSize[2]-(6+7)];
sdCardOffset = [35, 80, boxSize[2]-6];
resetButtonOffset = [encoderOffset[0]+14/2, 68, 1];

//rotate([180, 0, 0])
{
  difference()
  {
    union()
    {
      // main mounting legs
      for(offset = [ [boxSize[0]-16, 0, boxSize[2]-7], [boxSize[0]-70, 0, boxSize[2]-7] ])
        translate(offset)
          cube([16, 40+13, 7]);
      // side mounting wing
      translate([15, 0, 6])
        cube([18, 20, 7]);

      difference()
      {
        // main working area
        cube(boxSize);
        // prusa's framework  corner
        translate([15, 0, 0])
          cube([143-15, 53, boxSize[2]]);
        // LCD
        translate(lcdOffset)
          lcdBoard();
        // encoder
        translate(encoderOffset)
        {
          translate([-2, -1/2, -8])
            cube([14+2*2, 12+1, 8+6]);
          menuKnob();
        }
        // SD card mount
        translate(sdCardOffset)
          rotate([0,180,0])
            sdCardReader();
        // reset button
        translate(resetButtonOffset)
        {
          translate([0, 0, -resetButtonOffset[2]])
            cylinder(r=(16+1)/2, h=boxSize[2])
          resetButton();
        }
        // cable guide drill
        translate([boxSize[0]-98-5, 40+16+6, 0])
          cableGuide();
        // side mounting wing cut-in, so that screw will hold tight
        cube([15, 40, 6]);
      }
    }

    // mounting drills
    for(offsetOY = [ 13/2+5/2, 40+13+5])
      for(offsetOX = [15/2, boxSize[0]-70+16/2, boxSize[0]-16/2])
        translate([offsetOX, offsetOY, -1])
          cylinder(r=5/2, h=6+7+2, $fs=1);
  }

  // LCD stub
  %translate(lcdOffset)
    lcdBoard();
  // encoder stub
  %translate(encoderOffset)
  {
    menuKnob();
    translate([7, 6, 23+4])
      rotate([180,0,0])
        menuKnobManipulator();
  }
  // SD card mount stub
  %translate(sdCardOffset)
    rotate([0,180,0])
      sdCardReader();
  // reset button stub
  %translate(resetButtonOffset)
    resetButton();
}


Create phosfor_1.scad

Create phosfor_1.scad

error: pathspec '3D-models/SCAD/phosfor_1.scad' did not match any file(s) known to git


The URL to the Thingiverse thing was updated.

/*
 * knurledFinishLib_v2.scad
 *
 * Written by aubenc @ Thingiverse
 *
 * This script is licensed under the Public Domain license.
 *
 * http://www.thingiverse.com/thing:32122
 *
 * Derived from knurledFinishLib.scad (also Public Domain license) available at
 *
 * http://www.thingiverse.com/thing:9095
 *
 * Usage:
 *
 *	 Drop this script somewhere where OpenSCAD can find it (your current project's
 *	 working directory/folder or your OpenSCAD libraries directory/folder).
 *
 *	 Add the line:
 *
 *		use <knurledFinishLib_v2.scad>
 *
 *	 in your OpenSCAD script and call either...
 *
 *    knurled_cyl( Knurled cylinder height,
 *                 Knurled cylinder outer diameter,
 *                 Knurl polyhedron width,
 *                 Knurl polyhedron height,
 *                 Knurl polyhedron depth,
 *                 Cylinder ends smoothed height,
 *                 Knurled surface smoothing amount );
 *
 *  ...or...
 *
 *    knurl();
 *
 *	If you use knurled_cyl() module, you need to specify the values for all and
 *
 *  Call the module ' help(); ' for a little bit more of detail
 *  and/or take a look to the PDF available at http://www.thingiverse.com/thing:9095
 *  for a in depth descrition of the knurl properties.
 */

module knurl(	k_cyl_hg	= 12,
					k_cyl_od	= 25,
					knurl_wd =  3,
					knurl_hg =  4,
					knurl_dp =  1.5,
					e_smooth =  2,
					s_smooth =  0)
{
    knurled_cyl(k_cyl_hg, k_cyl_od,
                knurl_wd, knurl_hg, knurl_dp,
                e_smooth, s_smooth);
}

module knurled_cyl(chg, cod, cwd, csh, cdp, fsh, smt)
{
    cord=(cod+cdp+cdp*smt/100)/2;
    cird=cord-cdp;
    cfn=round(2*cird*PI/cwd);
    clf=360/cfn;
    crn=ceil(chg/csh);

//    echo("knurled cylinder max diameter: ", 2*cord);
//    echo("knurled cylinder min diameter: ", 2*cird);

	 if( fsh < 0 )
    {
        union()
        {
            shape(fsh, cird+cdp*smt/100, cord, cfn*4, chg);

            translate([0,0,-(crn*csh-chg)/2])
              knurled_finish(cord, cird, clf, csh, cfn, crn);
        }
    }
    else if ( fsh == 0 )
    {
        intersection()
        {
            cylinder(h=chg, r=cord-cdp*smt/100, $fn=2*cfn, center=false);

            translate([0,0,-(crn*csh-chg)/2])
              knurled_finish(cord, cird, clf, csh, cfn, crn);
        }
    }
    else
    {
        intersection()
        {
            shape(fsh, cird, cord-cdp*smt/100, cfn*4, chg);

            translate([0,0,-(crn*csh-chg)/2])
              knurled_finish(cord, cird, clf, csh, cfn, crn);
        }
    }
}

module shape(hsh, ird, ord, fn4, hg)
{
	x0= 0;	x1 = hsh > 0 ? ird : ord;		x2 = hsh > 0 ? ord : ird;
	y0=-0.1;	y1=0;	y2=abs(hsh);	y3=hg-abs(hsh);	y4=hg;	y5=hg+0.1;

	if ( hsh >= 0 )
	{
		rotate_extrude(convexity=10, $fn=fn4)
		polygon(points=[	[x0,y1],[x1,y1],[x2,y2],[x2,y3],[x1,y4],[x0,y4]	],
					paths=[	[0,1,2,3,4,5]	]);
	}
	else
	{
		rotate_extrude(convexity=10, $fn=fn4)
		polygon(points=[	[x0,y0],[x1,y0],[x1,y1],[x2,y2],
								[x2,y3],[x1,y4],[x1,y5],[x0,y5]	],
					paths=[	[0,1,2,3,4,5,6,7]	]);
	}
}

module knurled_finish(ord, ird, lf, sh, fn, rn)
{
    for(j=[0:rn-1])
    assign(h0=sh*j, h1=sh*(j+1/2), h2=sh*(j+1))
    {
        for(i=[0:fn-1])
        assign(lf0=lf*i, lf1=lf*(i+1/2), lf2=lf*(i+1))
        {
            polyhedron(
                points=[
                     [ 0,0,h0],
                     [ ord*cos(lf0), ord*sin(lf0), h0],
                     [ ird*cos(lf1), ird*sin(lf1), h0],
                     [ ord*cos(lf2), ord*sin(lf2), h0],

                     [ ird*cos(lf0), ird*sin(lf0), h1],
                     [ ord*cos(lf1), ord*sin(lf1), h1],
                     [ ird*cos(lf2), ird*sin(lf2), h1],

                     [ 0,0,h2],
                     [ ord*cos(lf0), ord*sin(lf0), h2],
                     [ ird*cos(lf1), ird*sin(lf1), h2],
                     [ ord*cos(lf2), ord*sin(lf2), h2]
                    ],
                triangles=[
                     [0,1,2],[2,3,0],
                     [1,0,4],[4,0,7],[7,8,4],
                     [8,7,9],[10,9,7],
                     [10,7,6],[6,7,0],[3,6,0],
                     [2,1,4],[3,2,6],[10,6,9],[8,9,4],
                     [4,5,2],[2,5,6],[6,5,9],[9,5,4]
                    ],
                convexity=5);
         }
    }
}

module knurl_help()
{
	echo();
	echo("    Knurled Surface Library  v2  ");
   echo("");
	echo("      Modules:    ");
	echo("");
	echo("        knurled_cyl(parameters... );    -    Requires a value for each an every expected parameter (see bellow)    ");
	echo("");
	echo("        knurl();    -    Call to the previous module with a set of default parameters,    ");
	echo("                                  values may be changed by adding 'parameter_name=value'        i.e.     knurl(s_smooth=40);    ");
	echo("");
	echo("      Parameters, all of them in mm but the last one.    ");
	echo("");
	echo("        k_cyl_hg       -   [ 12   ]  ,,  Height for the knurled cylinder    ");
	echo("        k_cyl_od      -   [ 25   ]  ,,  Cylinder's Outer Diameter before applying the knurled surfacefinishing.    ");
	echo("        knurl_wd     -   [   3   ]  ,,  Knurl's Width.    ");
	echo("        knurl_hg      -   [   4   ]  ,,  Knurl's Height.    ");
	echo("        knurl_dp     -   [  1.5 ]  ,,  Knurl's Depth.    ");
	echo("        e_smooth   -    [  2   ]  ,,  Bevel's Height at the bottom and the top of the cylinder    ");
	echo("        s_smooth   -    [  0   ]  ,,  Knurl's Surface Smoothing :  File donwn the top of the knurl this value, i.e. 40 will snooth it a 40%.    ");
	echo("");
}

/*
 * knurledFinishLib_v2.scad
 *
 * Written by aubenc @ Thingiverse
 *
 * This script is licensed under the Public Domain license.
 *
 * http://www.thingiverse.com/thing:31122
 *
 * Derived from knurledFinishLib.scad (also Public Domain license) available at
 *
 * http://www.thingiverse.com/thing:9095
 *
 * Usage:
 *
 *	 Drop this script somewhere where OpenSCAD can find it (your current project's
 *	 working directory/folder or your OpenSCAD libraries directory/folder).
 *
 *	 Add the line:
 *
 *		use <knurledFinishLib_v2.scad>
 *
 *	 in your OpenSCAD script and call either...
 *
 *    knurled_cyl( Knurled cylinder height,
 *                 Knurled cylinder outer diameter,
 *                 Knurl polyhedron width,
 *                 Knurl polyhedron height,
 *                 Knurl polyhedron depth,
 *                 Cylinder ends smoothed height,
 *                 Knurled surface smoothing amount );
 *
 *  ...or...
 *
 *    knurl();
 *
 *	If you use knurled_cyl() module, you need to specify the values for all and
 *
 *  Call the module ' help(); ' for a little bit more of detail
 *  and/or take a look to the PDF available at http://www.thingiverse.com/thing:9095
 *  for a in depth descrition of the knurl properties.
 */

module knurl(	k_cyl_hg	= 12,
					k_cyl_od	= 25,
					knurl_wd =  3,
					knurl_hg =  4,
					knurl_dp =  1.5,
					e_smooth =  2,
					s_smooth =  0)
{
    knurled_cyl(k_cyl_hg, k_cyl_od,
                knurl_wd, knurl_hg, knurl_dp,
                e_smooth, s_smooth);
}

module knurled_cyl(chg, cod, cwd, csh, cdp, fsh, smt)
{
    cord=(cod+cdp+cdp*smt/100)/2;
    cird=cord-cdp;
    cfn=round(2*cird*PI/cwd);
    clf=360/cfn;
    crn=ceil(chg/csh);

//    echo("knurled cylinder max diameter: ", 2*cord);
//    echo("knurled cylinder min diameter: ", 2*cird);

	 if( fsh < 0 )
    {
        union()
        {
            shape(fsh, cird+cdp*smt/100, cord, cfn*4, chg);

            translate([0,0,-(crn*csh-chg)/2])
              knurled_finish(cord, cird, clf, csh, cfn, crn);
        }
    }
    else if ( fsh == 0 )
    {
        intersection()
        {
            cylinder(h=chg, r=cord-cdp*smt/100, $fn=2*cfn, center=false);

            translate([0,0,-(crn*csh-chg)/2])
              knurled_finish(cord, cird, clf, csh, cfn, crn);
        }
    }
    else
    {
        intersection()
        {
            shape(fsh, cird, cord-cdp*smt/100, cfn*4, chg);

            translate([0,0,-(crn*csh-chg)/2])
              knurled_finish(cord, cird, clf, csh, cfn, crn);
        }
    }
}

module shape(hsh, ird, ord, fn4, hg)
{
	x0= 0;	x1 = hsh > 0 ? ird : ord;		x2 = hsh > 0 ? ord : ird;
	y0=-0.1;	y1=0;	y2=abs(hsh);	y3=hg-abs(hsh);	y4=hg;	y5=hg+0.1;

	if ( hsh >= 0 )
	{
		rotate_extrude(convexity=10, $fn=fn4)
		polygon(points=[	[x0,y1],[x1,y1],[x2,y2],[x2,y3],[x1,y4],[x0,y4]	],
					paths=[	[0,1,2,3,4,5]	]);
	}
	else
	{
		rotate_extrude(convexity=10, $fn=fn4)
		polygon(points=[	[x0,y0],[x1,y0],[x1,y1],[x2,y2],
								[x2,y3],[x1,y4],[x1,y5],[x0,y5]	],
					paths=[	[0,1,2,3,4,5,6,7]	]);
	}
}

module knurled_finish(ord, ird, lf, sh, fn, rn)
{
    for(j=[0:rn-1])
    assign(h0=sh*j, h1=sh*(j+1/2), h2=sh*(j+1))
    {
        for(i=[0:fn-1])
        assign(lf0=lf*i, lf1=lf*(i+1/2), lf2=lf*(i+1))
        {
            polyhedron(
                points=[
                     [ 0,0,h0],
                     [ ord*cos(lf0), ord*sin(lf0), h0],
                     [ ird*cos(lf1), ird*sin(lf1), h0],
                     [ ord*cos(lf2), ord*sin(lf2), h0],

                     [ ird*cos(lf0), ird*sin(lf0), h1],
                     [ ord*cos(lf1), ord*sin(lf1), h1],
                     [ ird*cos(lf2), ird*sin(lf2), h1],

                     [ 0,0,h2],
                     [ ord*cos(lf0), ord*sin(lf0), h2],
                     [ ird*cos(lf1), ird*sin(lf1), h2],
                     [ ord*cos(lf2), ord*sin(lf2), h2]
                    ],
                triangles=[
                     [0,1,2],[2,3,0],
                     [1,0,4],[4,0,7],[7,8,4],
                     [8,7,9],[10,9,7],
                     [10,7,6],[6,7,0],[3,6,0],
                     [2,1,4],[3,2,6],[10,6,9],[8,9,4],
                     [4,5,2],[2,5,6],[6,5,9],[9,5,4]
                    ],
                convexity=5);
         }
    }
}

module knurl_help()
{
	echo();
	echo("    Knurled Surface Library  v2  ");
   echo("");
	echo("      Modules:    ");
	echo("");
	echo("        knurled_cyl(parameters... );    -    Requires a value for each an every expected parameter (see bellow)    ");
	echo("");
	echo("        knurl();    -    Call to the previous module with a set of default parameters,    ");
	echo("                                  values may be changed by adding 'parameter_name=value'        i.e.     knurl(s_smooth=40);    ");
	echo("");
	echo("      Parameters, all of them in mm but the last one.    ");
	echo("");
	echo("        k_cyl_hg       -   [ 12   ]  ,,  Height for the knurled cylinder    ");
	echo("        k_cyl_od      -   [ 25   ]  ,,  Cylinder's Outer Diameter before applying the knurled surfacefinishing.    ");
	echo("        knurl_wd     -   [   3   ]  ,,  Knurl's Width.    ");
	echo("        knurl_hg      -   [   4   ]  ,,  Knurl's Height.    ");
	echo("        knurl_dp     -   [  1.5 ]  ,,  Knurl's Depth.    ");
	echo("        e_smooth   -    [  2   ]  ,,  Bevel's Height at the bottom and the top of the cylinder    ");
	echo("        s_smooth   -    [  0   ]  ,,  Knurl's Surface Smoothing :  File donwn the top of the knurl this value, i.e. 40 will snooth it a 40%.    ");
	echo("");
}


Cladding done

Cladding done

shed_length = 5184;
shed_width = 1981;
shed_front_height = 2250;
//shed_back_height = 2030;

window_w=1830;
window_h=920;
door_w=858; // 1981 x 838mm + 20
door_h=1991; // 1981 x 838mm + 20
shed_back_height = door_h;

space_to_window_w=window_w/2;
space_to_window_h=door_h-window_h;
space_to_door_w=window_w + 2*space_to_window_w;

base_timber_w = 47;
base_timber_h = 75;
timber_construct_w = 38;
timber_construct_h = 63;
timber_length_unit=2400;
base_sheet_t = 18;
sheet_width = 1220;
sheet_length = 2440;

wrap_t = 1;

first_layer = base_timber_h+wrap_t+base_sheet_t;

opp = shed_front_height-shed_back_height;
adj = shed_width -timber_construct_h;
hyp = sqrt(opp*opp+adj*adj);
theta = atan(opp/adj);
thin_opp = tan(theta) * timber_construct_h;

echo("Theta ", theta);

module cubeI(size,comment="//", center=false)
{
    if (comment != "//")
        echo(comment);
    // Cube - but will echo dimensions in order of size
    if( (size[0]>size[1]) && (size[1]>=size[2]) )
       echo( size[0], size[1], size[2]);
    if( (size[0]>size[2]) && (size[2]>size[1]) )
       echo( size[0], size[2], size[1]);

    if( (size[1]>size[0]) && (size[0]>=size[2]) )
       echo( size[1], size[0], size[2]);
    if( (size[1]>size[2]) && (size[2]>size[0]) )
       echo( size[1], size[2], size[0]);

    if( (size[2]>size[0]) && (size[0]>=size[1]) )
       echo( size[2], size[0], size[1]);
    if( (size[2]>size[1]) && (size[1]>size[0]) )
       echo( size[2], size[1], size[0]);

    cube(size, center=center);
}

module houseWrapLayer(width,length, overlap=100)
{
    echo("House Wrap",width+overlap,length+overlap);
    color("Black",0.75)
    {
        cube([width, length, wrap_t]);
        cube([width, wrap_t, overlap]);
        translate([0,length-wrap_t,0]) cube([width, wrap_t, overlap]);
        cube([wrap_t, length, overlap]);
        translate([width-wrap_t,0,0]) cube([wrap_t, length, overlap]);
    }
}

module beamsWrap()
{

    translate([0,shed_width,first_layer])  rotate([90,0,0]) houseWrapLayer(shed_length,shed_back_height, overlap=100);

    translate([0,-1,first_layer])  rotate([90,0,90]) difference()
        {
        houseWrapLayer(shed_width,shed_front_height+timber_construct_h, overlap=100);
        translate([-opp,shed_front_height+timber_construct_h,-opp]) rotate([0,0,-theta]) cube([shed_width*2,opp*2, opp*2]);
        }

     translate([shed_length,shed_width-1,first_layer])  rotate([90,0,-90]) difference()
        {
        houseWrapLayer(shed_width,shed_front_height+timber_construct_h, overlap=100);
        translate([-opp,shed_front_height-opp,-opp]) rotate([0,0,theta]) cube([shed_width*2,opp*2, opp*2]);
        }
    difference()
        {
            translate([shed_length,-2,first_layer])  rotate([90,0,180]) houseWrapLayer(shed_length,shed_front_height, overlap=100);
           translate([space_to_window_w, -50, space_to_window_h+first_layer]) cube([window_w, 100, window_h]);
           translate([space_to_door_w, -50, first_layer]) cube([door_w, 100, door_h]);
        }

}

module OSB(size,center=false)
{
    echo("OSB");
    cubeI(size,center=center);
}

module floorPanel(width,length)
{
/*
    echo("Timber");
    //Timber supporting base along left side
    cubeI([base_timber_w, length, base_timber_h]);
    //Timber supporting base along right side
    translate([width-base_timber_w,0,0])  cubeI([base_timber_w, length, base_timber_h]);
    //Timber supporting base Middle of I
    translate([base_timber_w,(length-base_timber_h)/2,base_timber_h-base_timber_w])  cubeI([width-base_timber_w*2, base_timber_h, base_timber_w]);
*/
    //DuPont Tyvek Housewrap - 100m 1.4m
    translate([0,0,base_timber_h]) houseWrapLayer(width,length,overlap=25);

    //OSB Board - although the board is not cut by 1 mm (wrap_t) in each
    //              direction for drawing purposes it is shaved
    translate([wrap_t,wrap_t,base_timber_h+wrap_t]) OSB([width-wrap_t*2,length-wrap_t*2,base_sheet_t]);
}

module floorBeams(width = shed_width, length = shed_length, overlap = 150, cross_beams=5)
{
    echo("floorBeams");
    // from one end along the front
    translate([0,0,0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    // from oother end along the front
    translate([length-timber_length_unit, 0, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([timber_length_unit-overlap, base_timber_w, 0]) cubeI([length-2*(timber_length_unit-overlap), base_timber_w, base_timber_h]);

    //Again at the back
    // from one end along the front
    translate([0,width-base_timber_w,0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    // from oother end along the front
    translate([length-timber_length_unit, width-base_timber_w, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([timber_length_unit-overlap, width-base_timber_w*2, 0]) cubeI([length-2*(timber_length_unit-overlap), base_timber_w, base_timber_h]);

    //Each end of shed
    translate([0, base_timber_w, base_timber_h-base_timber_w]) cubeI([base_timber_h, width-base_timber_w*2, base_timber_w]);
    translate([length-base_timber_h, base_timber_w, base_timber_h-base_timber_w]) cubeI([base_timber_h, width-base_timber_w*2, base_timber_w]);

    // Middle suport
    translate([base_timber_h, (width-base_timber_w)/2, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([length-base_timber_h-timber_length_unit, (width-base_timber_w)/2, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([timber_length_unit+base_timber_h-overlap, (width-base_timber_w)/2+base_timber_w, 0]) cubeI([length-2*timber_length_unit+overlap, base_timber_w, base_timber_h]);

   // Middle Cross beams0
   translate([(length-base_timber_w)/2-base_timber_h/2, base_timber_w*2, base_timber_h-base_timber_w]) cubeI([base_timber_h, (width-3*base_timber_w)/2, base_timber_w]);
    translate([(length-base_timber_w)/2+base_timber_h/2, base_timber_w*3+(width-3*base_timber_w)/2, base_timber_h-base_timber_w]) cubeI([base_timber_h, (width-3*base_timber_w)/2-2*base_timber_w, base_timber_w]);

}

module floorPanels(width = shed_width, length = shed_length)
{
    echo("floorPanels");
    sheet_width_inc_wrap = sheet_width + 2*wrap_t;
    num_width_panels = round(-0.5+length/sheet_width_inc_wrap);
    for(base_x = [0 : num_width_panels-1])
    {
        translate([base_x*sheet_width_inc_wrap, 0, 0]) floorPanel(sheet_width_inc_wrap,width);
    }
    full_panels_width = sheet_width_inc_wrap*num_width_panels;
    translate([full_panels_width, 0, 0]) floorPanel(length-full_panels_width,width);
}

module verticalStruts(width, height, beams=0, extra_struct=0)
{
    cubeI([width,timber_construct_h,timber_construct_w]);
    translate([0,0,height-timber_construct_w]) cubeI([width,timber_construct_h,timber_construct_w]);
    translate([0,0,timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-timber_construct_w*2]);
    translate([width-timber_construct_w,0,timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-timber_construct_w*2]);

    if(beams>0 && extra_struct==0)
    {
        middle_height = height-timber_construct_w*2;
        beam_spacing = middle_height/(beams+1);
        for(loop=[1:beams])
        {
            translate([timber_construct_w, 0, beam_spacing*loop]) cubeI([width-timber_construct_w*2,timber_construct_h,timber_construct_w]);
        }
    }
    if(beams==0 && extra_struct>0)
    {
        middle_width = width-timber_construct_w*1;
        beam_spacing = middle_width/(extra_struct+1);
        for(loop=[1:extra_struct])
        {
            translate([beam_spacing*loop, 0, timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-2*timber_construct_w]);
        }
    }
    if(beams>0 && extra_struct>0)
    {
        middle_height = height-timber_construct_w*2;
        beam_spacing_h = middle_height/(beams+1);
        middle_width = width-timber_construct_w*1;
        beam_spacing_w = middle_width/(extra_struct+1);

        // Wee need to off set, so we divide by mod 2
        // move the all the beams down by timber_construct_w
        // but add loop mod 2 * timber_construct_w
        // (hence odd move up, even remain down

        for(loop=[0:extra_struct])
        {
            if (loop>0)
                translate([beam_spacing_w*loop, 0, timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-2*timber_construct_w]);
            for(loop_b=[1:beams])
            {
                offset = - timber_construct_w + (timber_construct_w * (loop%2));
                translate([timber_construct_w+beam_spacing_w*loop, 0, beam_spacing_h*loop_b+offset]) cubeI([beam_spacing_w-timber_construct_w,timber_construct_h,timber_construct_w]);
            }
        }
    }
}

module backStructs(width = shed_length, height = shed_back_height, structs_sets=3, beams=2, extra_struct=1)
{
    echo("backStructs");
    translate([wrap_t,shed_width-timber_construct_h-wrap_t,first_layer])
    {
        struct_set_w = (width-wrap_t*2)/structs_sets;
        for(structs=[0:structs_sets-1])
        {
            echo("backStructs - Section");
            translate([structs*struct_set_w,0,0]) verticalStruts(struct_set_w, height, beams=beams, extra_struct=extra_struct);
        }
    }

}

module sideStructs(width = shed_width, height = shed_back_height, beams=2, extra_struct=2)
{
    echo("SideStructs");
    translate([timber_construct_h+wrap_t,timber_construct_h,first_layer])
    {
        rotate([0,0,90]) verticalStruts(width-timber_construct_h*2, height, beams=beams, extra_struct=extra_struct);
    }
}

module leftSideStructs()
{
    echo("leftSideStructs");
    sideStructs();
}

module rightSideStructs()
{
    echo("rightSideStructs");
    translate([shed_length-timber_construct_h-wrap_t*2,0,0]) sideStructs();
}

module frontStructs()
{
    echo("frontStructs");
    translate([wrap_t,-wrap_t,first_layer+1])
    {
        verticalStruts(space_to_window_w, door_h, beams=2, extra_struct=0);
        translate([space_to_window_w,0,0]) verticalStruts(window_w, space_to_window_h, beams=1, extra_struct=2);
        translate([space_to_window_w+window_w,0,0])  verticalStruts(space_to_window_w, door_h, beams=2, extra_struct=1);
        translate([space_to_door_w+door_w,0,0])  verticalStruts(shed_length-(space_to_door_w+door_w), door_h, beams=2, extra_struct=0);
        // top part, which is longer than a standard timber_length_unit
        gap = (space_to_door_w - timber_length_unit)/2;
        remainder = shed_length - timber_length_unit - gap;
        translate([0,0,door_h])  verticalStruts(gap, shed_front_height-door_h, beams=0, extra_struct=0);
        translate([gap,0,door_h])  verticalStruts(timber_length_unit, shed_front_height-door_h, beams=0, extra_struct=2);
        translate([timber_length_unit + gap,0,door_h])  verticalStruts(remainder, shed_front_height-door_h, beams=0, extra_struct=2);
    }
}

module roof()
{
    echo("roof");
    // hyp
    inner_width = hyp+timber_construct_h;
    flat_offset = (sheet_length - inner_width)/2;

    translate([-flat_offset,-wrap_t,shed_front_height+ first_layer +1 +thin_opp ]) rotate([-theta,0,0])
    {
        frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2, left_offset=flat_offset);
        translate([sheet_width*4,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2, right_offset=flat_offset, sw= shed_length - sheet_width*4+flat_offset*2);

        translate([sheet_width,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2);
        translate([sheet_width*2,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2);
        translate([sheet_width*3,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2);
    }
}

module frameSheet(left_offset=0, right_offset=0, front_offset=0, back_offset=0, sheet_left_offset=0, sheet_right_offset=0, sheet_front_offset=0, sheet_back_offset=0, sw=sheet_width, sl = sheet_length)
{
    translate([left_offset, front_offset, 0]) cubeI([timber_construct_h, sl-front_offset-back_offset, timber_construct_w]);
    translate([sw-right_offset-timber_construct_h, front_offset, 0]) cubeI([timber_construct_h, sl-front_offset-back_offset, timber_construct_w]);

   beam_l = (sw-left_offset-right_offset-3*timber_construct_h)/2;

    translate([left_offset+beam_l+timber_construct_h, front_offset, 0]) cubeI([timber_construct_h, sl-front_offset-back_offset, timber_construct_w]);

   translate([left_offset+timber_construct_h, front_offset, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);
   translate([left_offset+timber_construct_h+beam_l+timber_construct_h, front_offset, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);

    translate([left_offset+timber_construct_h, sl - back_offset-timber_construct_h, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);
    translate([left_offset+timber_construct_h+beam_l+timber_construct_h, sl - back_offset-timber_construct_h, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);

    translate([sheet_left_offset, sheet_front_offset, timber_construct_w]) OSB([sw-sheet_back_offset,sl-sheet_right_offset, base_sheet_t]);
    mirror([0,0,1]) translate([sheet_left_offset, sheet_front_offset, -timber_construct_w-base_sheet_t-wrap_t])
        houseWrapLayer(sw-sheet_back_offset+2*wrap_t,sl-sheet_right_offset+2*wrap_t, overlap=25);
}

module prism(l, w, h)
{
    polyhedron(
        points=[[0,0,0], [l,0,0], [l,w,0], [0,w,0], [0,w,h], [l,w,h]],
        faces=[[0,1,2,3],[5,4,3,2],[0,4,5,1],[0,3,4],[5,2,1]]
        );
}

module cadding(x, board_height, board_width_b, board_width_s, degrees)
{
    echo("Cladding: ",  x, board_height);
    translate([0, -board_width_b, 0]) color("Peru",0.6) rotate([-degrees,0,0])
    {
        cube([x, board_width_b - board_width_s, board_height]);
        translate([0,- board_width_s,0]) prism(x, board_width_s, board_height);
    }
}

module caddings(x, z, board_height = 150, board_width_b = 11, board_width_s = 6, overlap = 34, degrees=3)
{
    panel_uplift = board_height - overlap;
    panels = round(-0.5+z/panel_uplift);
    for(p = [0 : panels-1])
    {
        translate([0,0,panel_uplift * p])
         cadding(x, board_height, board_width_b, board_width_s, degrees);
    }
}

module claddingBackWall()
{
    translate([shed_length,shed_width,first_layer]) rotate([0,0,180]) caddings(shed_length, shed_back_height);
}

module claddingLeftWall()
{
    translate([0,shed_width,first_layer]) rotate([0,0,180+90])
    difference()
    {
        caddings(shed_width, shed_front_height);
        translate([-opp,-opp,shed_front_height-opp]) rotate([0,-theta,0]) cube([shed_width*2,opp*2, opp*2]);
    }
}

module claddingRightWall()
{
    translate([shed_length,0,first_layer]) rotate([0,0,180-90])
    difference()
    {
        caddings(shed_width, shed_front_height);
        translate([-opp,-opp,shed_back_height+opp+base_timber_h]) rotate([0,theta,0]) cube([shed_width*2,opp*2, opp*2]);
    }
}

module claddingFrontWall()
{
    translate([0,0,first_layer]) rotate([0,0,0])
        difference()
    {
        caddings(shed_length, shed_front_height);
           translate([space_to_window_w, -50, space_to_window_h]) cube([window_w, 100, window_h]);
           translate([space_to_door_w, -50, 0]) cube([door_w, 100, door_h]);
    }
}

floorBeams();

floorPanels();

backStructs();

leftSideStructs();
rightSideStructs();

frontStructs();
roof();

beamsWrap();

claddingBackWall();
claddingLeftWall();
claddingRightWall();
claddingFrontWall();

shed_length = 5184;
shed_width = 1981;
shed_front_height = 2250;
//shed_back_height = 2030;

window_w=1830;
window_h=920;
door_w=858; // 1981 x 838mm + 20
door_h=1991; // 1981 x 838mm + 20
shed_back_height = door_h;

space_to_window_w=window_w/2;
space_to_window_h=door_h-window_h;
space_to_door_w=window_w + 2*space_to_window_w;

base_timber_w = 47;
base_timber_h = 75;
timber_construct_w = 38;
timber_construct_h = 63;
timber_length_unit=2400;
base_sheet_t = 18;
sheet_width = 1220;
sheet_length = 2440;

wrap_t = 1;

first_layer = base_timber_h+wrap_t+base_sheet_t;

opp = shed_front_height-shed_back_height;
adj = shed_width -timber_construct_h;
hyp = sqrt(opp*opp+adj*adj);
theta = atan(opp/adj);
thin_opp = tan(theta) * timber_construct_h;

echo("Theta ", theta);

module cubeI(size,comment="//", center=false)
{
    if (comment != "//")
        echo(comment);
    // Cube - but will echo dimensions in order of size
    if( (size[0]>size[1]) && (size[1]>=size[2]) )
       echo( size[0], size[1], size[2]);
    if( (size[0]>size[2]) && (size[2]>size[1]) )
       echo( size[0], size[2], size[1]);

    if( (size[1]>size[0]) && (size[0]>=size[2]) )
       echo( size[1], size[0], size[2]);
    if( (size[1]>size[2]) && (size[2]>size[0]) )
       echo( size[1], size[2], size[0]);

    if( (size[2]>size[0]) && (size[0]>=size[1]) )
       echo( size[2], size[0], size[1]);
    if( (size[2]>size[1]) && (size[1]>size[0]) )
       echo( size[2], size[1], size[0]);

    cube(size, center=center);
}

module houseWrapLayer(width,length, overlap=100)
{
    echo("House Wrap",width+overlap,length+overlap);
    color("Black",0.75)
    {
        cube([width, length, wrap_t]);
        cube([width, wrap_t, overlap]);
        translate([0,length-wrap_t,0]) cube([width, wrap_t, overlap]);
        cube([wrap_t, length, overlap]);
        translate([width-wrap_t,0,0]) cube([wrap_t, length, overlap]);
    }
}

module beamsWrap()
{

    translate([0,shed_width,first_layer])  rotate([90,0,0]) houseWrapLayer(shed_length,shed_back_height, overlap=100);

    translate([0,-1,first_layer])  rotate([90,0,90]) difference()
        {
        houseWrapLayer(shed_width,shed_front_height+timber_construct_h, overlap=100);
        translate([-opp,shed_front_height+timber_construct_h,-opp]) rotate([0,0,-theta]) cube([shed_width*2,opp*2, opp*2]);
        }

     translate([shed_length,shed_width-1,first_layer])  rotate([90,0,-90]) difference()
        {
        houseWrapLayer(shed_width,shed_front_height+timber_construct_h, overlap=100);
        translate([-opp,shed_front_height-opp,-opp]) rotate([0,0,theta]) cube([shed_width*2,opp*2, opp*2]);
        }

}

module OSB(size,center=false)
{
    echo("OSB");
    cubeI(size,center=center);
}

module floorPanel(width,length)
{
/*
    echo("Timber");
    //Timber supporting base along left side
    cubeI([base_timber_w, length, base_timber_h]);
    //Timber supporting base along right side
    translate([width-base_timber_w,0,0])  cubeI([base_timber_w, length, base_timber_h]);
    //Timber supporting base Middle of I
    translate([base_timber_w,(length-base_timber_h)/2,base_timber_h-base_timber_w])  cubeI([width-base_timber_w*2, base_timber_h, base_timber_w]);
*/
    //DuPont Tyvek Housewrap - 100m 1.4m
    translate([0,0,base_timber_h]) houseWrapLayer(width,length,overlap=25);

    //OSB Board - although the board is not cut by 1 mm (wrap_t) in each
    //              direction for drawing purposes it is shaved
    translate([wrap_t,wrap_t,base_timber_h+wrap_t]) OSB([width-wrap_t*2,length-wrap_t*2,base_sheet_t]);
}

module floorBeams(width = shed_width, length = shed_length, overlap = 150, cross_beams=5)
{
    echo("floorBeams");
    // from one end along the front
    translate([0,0,0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    // from oother end along the front
    translate([length-timber_length_unit, 0, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([timber_length_unit-overlap, base_timber_w, 0]) cubeI([length-2*(timber_length_unit-overlap), base_timber_w, base_timber_h]);

    //Again at the back
    // from one end along the front
    translate([0,width-base_timber_w,0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    // from oother end along the front
    translate([length-timber_length_unit, width-base_timber_w, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([timber_length_unit-overlap, width-base_timber_w*2, 0]) cubeI([length-2*(timber_length_unit-overlap), base_timber_w, base_timber_h]);

    //Each end of shed
    translate([0, base_timber_w, base_timber_h-base_timber_w]) cubeI([base_timber_h, width-base_timber_w*2, base_timber_w]);
    translate([length-base_timber_h, base_timber_w, base_timber_h-base_timber_w]) cubeI([base_timber_h, width-base_timber_w*2, base_timber_w]);

    // Middle suport
    translate([base_timber_h, (width-base_timber_w)/2, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([length-base_timber_h-timber_length_unit, (width-base_timber_w)/2, 0]) cubeI([timber_length_unit, base_timber_w, base_timber_h]);
    translate([timber_length_unit+base_timber_h-overlap, (width-base_timber_w)/2+base_timber_w, 0]) cubeI([length-2*timber_length_unit+overlap, base_timber_w, base_timber_h]);

   // Middle Cross beams0
   translate([(length-base_timber_w)/2-base_timber_h/2, base_timber_w*2, base_timber_h-base_timber_w]) cubeI([base_timber_h, (width-3*base_timber_w)/2, base_timber_w]);
    translate([(length-base_timber_w)/2+base_timber_h/2, base_timber_w*3+(width-3*base_timber_w)/2, base_timber_h-base_timber_w]) cubeI([base_timber_h, (width-3*base_timber_w)/2-2*base_timber_w, base_timber_w]);

}

module floorPanels(width = shed_width, length = shed_length)
{
    echo("floorPanels");
    sheet_width_inc_wrap = sheet_width + 2*wrap_t;
    num_width_panels = round(-0.5+length/sheet_width_inc_wrap);
    for(base_x = [0 : num_width_panels-1])
    {
        translate([base_x*sheet_width_inc_wrap, 0, 0]) floorPanel(sheet_width_inc_wrap,width);
    }
    full_panels_width = sheet_width_inc_wrap*num_width_panels;
    translate([full_panels_width, 0, 0]) floorPanel(length-full_panels_width,width);
}

module verticalStruts(width, height, beams=0, extra_struct=0)
{
    cubeI([width,timber_construct_h,timber_construct_w]);
    translate([0,0,height-timber_construct_w]) cubeI([width,timber_construct_h,timber_construct_w]);
    translate([0,0,timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-timber_construct_w*2]);
    translate([width-timber_construct_w,0,timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-timber_construct_w*2]);

    if(beams>0 && extra_struct==0)
    {
        middle_height = height-timber_construct_w*2;
        beam_spacing = middle_height/(beams+1);
        for(loop=[1:beams])
        {
            translate([timber_construct_w, 0, beam_spacing*loop]) cubeI([width-timber_construct_w*2,timber_construct_h,timber_construct_w]);
        }
    }
    if(beams==0 && extra_struct>0)
    {
        middle_width = width-timber_construct_w*1;
        beam_spacing = middle_width/(extra_struct+1);
        for(loop=[1:extra_struct])
        {
            translate([beam_spacing*loop, 0, timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-2*timber_construct_w]);
        }
    }
    if(beams>0 && extra_struct>0)
    {
        middle_height = height-timber_construct_w*2;
        beam_spacing_h = middle_height/(beams+1);
        middle_width = width-timber_construct_w*1;
        beam_spacing_w = middle_width/(extra_struct+1);

        // Wee need to off set, so we divide by mod 2
        // move the all the beams down by timber_construct_w
        // but add loop mod 2 * timber_construct_w
        // (hence odd move up, even remain down

        for(loop=[0:extra_struct])
        {
            if (loop>0)
                translate([beam_spacing_w*loop, 0, timber_construct_w]) cubeI([timber_construct_w,timber_construct_h,height-2*timber_construct_w]);
            for(loop_b=[1:beams])
            {
                offset = - timber_construct_w + (timber_construct_w * (loop%2));
                translate([timber_construct_w+beam_spacing_w*loop, 0, beam_spacing_h*loop_b+offset]) cubeI([beam_spacing_w-timber_construct_w,timber_construct_h,timber_construct_w]);
            }
        }
    }
}

module backStructs(width = shed_length, height = shed_back_height, structs_sets=3, beams=2, extra_struct=1)
{
    echo("backStructs");
    translate([wrap_t,shed_width-timber_construct_h-wrap_t,first_layer])
    {
        struct_set_w = (width-wrap_t*2)/structs_sets;
        for(structs=[0:structs_sets-1])
        {
            echo("backStructs - Section");
            translate([structs*struct_set_w,0,0]) verticalStruts(struct_set_w, height, beams=beams, extra_struct=extra_struct);
        }
    }

}

module sideStructs(width = shed_width, height = shed_back_height, beams=2, extra_struct=2)
{
    echo("SideStructs");
    translate([timber_construct_h+wrap_t,timber_construct_h,first_layer])
    {
        rotate([0,0,90]) verticalStruts(width-timber_construct_h*2, height, beams=beams, extra_struct=extra_struct);
    }
}

module leftSideStructs()
{
    echo("leftSideStructs");
    sideStructs();
}

module rightSideStructs()
{
    echo("rightSideStructs");
    translate([shed_length-timber_construct_h-wrap_t*2,0,0]) sideStructs();
}

module frontStructs()
{
    echo("frontStructs");
    translate([wrap_t,-wrap_t,first_layer+1])
    {
        verticalStruts(space_to_window_w, door_h, beams=2, extra_struct=0);
        translate([space_to_window_w,0,0]) verticalStruts(window_w, space_to_window_h, beams=1, extra_struct=2);
        translate([space_to_window_w+window_w,0,0])  verticalStruts(space_to_window_w, door_h, beams=2, extra_struct=1);
        translate([space_to_door_w+door_w,0,0])  verticalStruts(shed_length-(space_to_door_w+door_w), door_h, beams=2, extra_struct=0);
        // top part, which is longer than a standard timber_length_unit
        gap = (space_to_door_w - timber_length_unit)/2;
        remainder = shed_length - timber_length_unit - gap;
        translate([0,0,door_h])  verticalStruts(gap, shed_front_height-door_h, beams=0, extra_struct=0);
        translate([gap,0,door_h])  verticalStruts(timber_length_unit, shed_front_height-door_h, beams=0, extra_struct=2);
        translate([timber_length_unit + gap,0,door_h])  verticalStruts(remainder, shed_front_height-door_h, beams=0, extra_struct=2);
    }
}

module roof()
{
    echo("roof");
    // hyp
    inner_width = hyp+timber_construct_h;
    flat_offset = (sheet_length - inner_width)/2;

    translate([-flat_offset,-wrap_t,shed_front_height+ first_layer +1 +thin_opp ]) rotate([-theta,0,0])
    {
        frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2, left_offset=flat_offset);
        translate([sheet_width*4,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2, right_offset=flat_offset, sw= shed_length - sheet_width*4+flat_offset*2);

        translate([sheet_width,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2);
        translate([sheet_width*2,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2);
        translate([sheet_width*3,0,0]) frameSheet( sheet_front_offset=-flat_offset*1.5, front_offset=0, back_offset=flat_offset*2);
        echo("FlatOffset", flat_offset);
    }
}

module frameSheet(left_offset=0, right_offset=0, front_offset=0, back_offset=0, sheet_left_offset=0, sheet_right_offset=0, sheet_front_offset=0, sheet_back_offset=0, sw=sheet_width, sl = sheet_length)
{
    translate([left_offset, front_offset, 0]) cubeI([timber_construct_h, sl-front_offset-back_offset, timber_construct_w]);
    translate([sw-right_offset-timber_construct_h, front_offset, 0]) cubeI([timber_construct_h, sl-front_offset-back_offset, timber_construct_w]);

   beam_l = (sw-left_offset-right_offset-3*timber_construct_h)/2;

    translate([left_offset+beam_l+timber_construct_h, front_offset, 0]) cubeI([timber_construct_h, sl-front_offset-back_offset, timber_construct_w]);

   translate([left_offset+timber_construct_h, front_offset, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);
   translate([left_offset+timber_construct_h+beam_l+timber_construct_h, front_offset, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);

    translate([left_offset+timber_construct_h, sl - back_offset-timber_construct_h, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);
    translate([left_offset+timber_construct_h+beam_l+timber_construct_h, sl - back_offset-timber_construct_h, 0]) cubeI([beam_l, timber_construct_h, timber_construct_w]);

    translate([sheet_left_offset, sheet_front_offset, timber_construct_w]) OSB([sw-sheet_back_offset,sl-sheet_right_offset, base_sheet_t]);
    mirror([0,0,1]) translate([sheet_left_offset, sheet_front_offset, -timber_construct_w-base_sheet_t-wrap_t])
        houseWrapLayer(sw-sheet_back_offset+2*wrap_t,sl-sheet_right_offset+2*wrap_t, overlap=25);
}

floorBeams();

floorPanels();

backStructs();

leftSideStructs();
rightSideStructs();

frontStructs();
roof();

beamsWrap();


cross will probably be a better tool

cross will probably be a better tool

cylinder(r=2, h=1, center=true, $fs=0.1);


parameterize the x,y scale

parameterize the x,y scale

base_xTranslate = 0;  // [-10: 0.1 :10]

base_yTranslate = 0;  // [-10: 0.1 :10]

stand_connectorBar_xLength = 8; // [-10: 0.1 :10]

stand_top_xTranslate = 8.105;  // [-10: 0.1 :10]

stand_top_yTranslate = 8.85;  // [-10: 0.1 :10]

iconType = "Mario";   // [Aqua Dude, Bass Clef, Cat, Creeper, Fan, Fish, Heart, Light Bulb, Luigi, Mario, Moon, Rebel, Spur, Sun, Thundercat, Treble Clef, Trooper]

iconColor = "blue"; // [pink, red, black, white, yellow, blue, green]

icon_xOffset = -9;  // [-30:30]

icon_yOffset = 34;  // [-10:200]

icon_zOffset = 19;  // [-30:30]

iconXyScale = 1.0;  // [-1: 0.1 :10]

bed_cutout_zLength = 10; // [4.2 : 15]

height = 40; // [19.125 : 60]

/* [Hidden] */

use <../../half-circle-phone-stand.scad>

halfCirclePhoneStand(base_xTranslate = base_xTranslate,
                     base_yTranslate = base_yTranslate,
                     bed_cutout_zLength = bed_cutout_zLength,
                     height = height,
                     iconColor = iconColor,
                     icon_xOffset = icon_xOffset,
                     icon_yOffset = icon_yOffset,
                     icon_zOffset = icon_zOffset,
                     iconXyScale = iconXyScale,
                     iconType = iconType,
                     stand_connectorBar_xLength = stand_connectorBar_xLength,
                     stand_top_xTranslate = stand_top_xTranslate,
                     stand_top_yTranslate = stand_top_yTranslate);

base_xTranslate = 0;  // [-10: 0.1 :10]

base_yTranslate = 0;  // [-10: 0.1 :10]

stand_connectorBar_xLength = 8; // [-10: 0.1 :10]

stand_top_xTranslate = 8.105;  // [-10: 0.1 :10]

stand_top_yTranslate = 8.85;  // [-10: 0.1 :10]

iconType = "Mario";   // [Aqua Dude, Bass Clef, Cat, Creeper, Fan, Fish, Heart, Light Bulb, Luigi, Mario, Moon, Rebel, Spur, Sun, Thundercat, Treble Clef, Trooper]

iconColor = "blue"; // [pink, red, black, white, yellow, blue, green]

icon_xOffset = -9;  // [-30:30]

icon_yOffset = 34;  // [-10:200]

icon_zOffset = 19;  // [-30:30]

bed_cutout_zLength = 10; // [4.2 : 15]

height = 40; // [19.125 : 60]

/* [Hidden] */

use <../../half-circle-phone-stand.scad>

halfCirclePhoneStand(base_xTranslate = base_xTranslate,
                     base_yTranslate = base_yTranslate,
                     bed_cutout_zLength = bed_cutout_zLength,
                     height = height,
                     iconColor = iconColor,
                     icon_xOffset = icon_xOffset,
                     icon_yOffset = icon_yOffset,
                     icon_zOffset = icon_zOffset,
                     iconType = iconType,
                     stand_connectorBar_xLength = stand_connectorBar_xLength,
                     stand_top_xTranslate = stand_top_xTranslate,
                     stand_top_yTranslate = stand_top_yTranslate);