Exemple #1
0
        public void Cylinder_BoundsAreInExpectedPositionCentered()
        {
            var obj = new Cylinder(5, 20, true);

            Assert.AreEqual(new Vector3(2.5, 2.5, 10), obj.Bounds().TopRight);
            Assert.AreEqual(new Vector3(-2.5, -2.5, -10), obj.Bounds().BottomLeft);
        }
Exemple #2
0
        public void Cylinder_ScriptOutputDoesNotContainResolutionValuesIfNotSpecified()
        {
            var cylinder = new Cylinder();

            string script = cylinder.ToString();

            Assert.IsTrue(!script.Contains("$fn"));
            Assert.IsTrue(!script.Contains("$fa"));
            Assert.IsTrue(!script.Contains("$fs"));
        }
Exemple #3
0
        public void Cylinder_ConstructorParametersAffectScriptOutput()
        {
            var cylinder = new Cylinder(5.5, 12.1, true);

            string script = cylinder.ToString();

            Assert.IsTrue(script.Contains("r1 = 2.75"));
            Assert.IsTrue(script.Contains("r2 = 2.75"));
            Assert.IsTrue(script.Contains("h = 12.1"));
            Assert.IsTrue(script.Contains("center = true"));
        }
Exemple #4
0
        public void Cylinder_ScriptOutpuHasResolutionValuesIfSpecified()
        {
            var cylinder = new Cylinder()
            {
                Resolution = 40,
                MinimumAngle = 5,
                MinimumCircumferentialLength = 2
            };

            string script = cylinder.ToString();

            Assert.IsTrue(script.Contains("$fn"));
            Assert.IsTrue(script.Contains("$fa"));
            Assert.IsTrue(script.Contains("$fs"));
        }
Exemple #5
0
        private static void makePeg()
        {
            OSCADObject flatInnerPortion = new Cylinder(Inches.Quarter, Inches.Eigth, true) { Resolution = 30 };
            OSCADObject shaft = new Cylinder(Inches.Eigth, Inches.Half, true) { Resolution = 30 };
            flatInnerPortion = flatInnerPortion.Translate(0, 0, shaft.Bounds().ZMax);

            OSCADObject pegShaft = new Cylinder(Inches.Quarter, Inches.Half - Inches.Eigth, true) { Resolution = 30 }
                .Translate(0, 0, -Inches.Eigth);
            OSCADObject bottomBall = new Sphere(Inches.Quarter* 1.1)
                .Translate(0, 0, pegShaft.Bounds().ZMin);

            var obj = flatInnerPortion + shaft + pegShaft + bottomBall;
            obj = obj.Rotate(0, 180, 0).Translate(0, 0, obj.Bounds().ZMax);

            obj.ToFile("peg");
        }
Exemple #6
0
        private static OSCADObject makeStandCap()
        {
            OSCADObject center = new Cube(Inches.One - Inches.Sixteenth, Inches.Half - Inches.Sixteenth, Inches.Quarter, true);

            OSCADObject outerColumn = new Cylinder(Inches.One, Inches.One, true).Resize(Inches.One * 1.5, Inches.Half * 1.5, Inches.One);
            var bnds = center.Bounds();

            OSCADObject top = new Cylinder(Inches.One, Inches.One, true)
                .Resize(Inches.One * 2.25, Inches.Half * 2.25, Inches.Quarter);
            OSCADObject cutout = new Cylinder(Inches.One, Inches.One, true)
                .Resize(Inches.One * 2.1, Inches.Half * 2.1, Inches.Quarter);
            top = top - cutout.Translate(0, 0, Inches.Quarter/2);


            OSCADObject brim = top.Clone();

            var obj = center + top.Translate(0, 0, bnds.Height / 2 + Inches.Sixteenth / 2);
            return obj;
        }
Exemple #7
0
        private static void makeLaserStand()
        {
            OSCADObject center = new Cube(Inches.One, Inches.Half, Inches.One*1.2, true);
            OSCADObject outerColumn = new Cylinder(Inches.One, Inches.One, true).Resize(Inches.One * 1.5, Inches.Half * 1.5, Inches.One);
            var bnds = outerColumn.Bounds();
            OSCADObject bottom = new Cylinder(Inches.One, Inches.One, true)
                .Resize(Inches.One * 2, Inches.Half * 2, Inches.One)
                .Translate(0, 0, 0);



            var obj = (outerColumn) + bottom;

            bnds = obj.Bounds();
            var cap = makeStandCap();

            obj = obj + cap.Translate(0, 0, bnds.ZMax - Inches.Sixteenth);

            obj.ToFile("laserStand2").Open();

        }
Exemple #8
0
        public static void makeHolder()
        {
            double innerSize = (Inches.One * 4);

            var cutout = new Cube(Inches.One * 10, Inches.Half, Inches.Half, true).Translate(0, innerSize/2, 0);

            cutout = cutout + cutout.Rotate(0, 0, 90) + cutout.Rotate(0, 0, 180) + cutout.Rotate(0, 0, 270);

            OSCADObject innerCyl = new Cylinder(innerSize, Inches.Eigth + Inches.Sixteenth, true) {
                Resolution = 60
            };
            var outerCyl = new Cylinder(innerSize + Inches.Eigth, Inches.Quarter + Inches.Sixteenth, true) {
                Resolution = 60
            };

            innerCyl = innerCyl.Translate(0, 0, outerCyl.Bounds().ZMax - (Inches.Eigth + Inches.Sixteenth)/2 + .1);
            var whole = (outerCyl - innerCyl) - cutout;
            whole.ToFile("coasterHolder-square").Open();
        }
Exemple #9
0
        public void Cylinder_CenteredCylinderPositionIsZero()
        {
            var cylinder = new Cylinder(5, 20, true);

            Assert.AreEqual(new Vector3(), cylinder.Position());
        }
Exemple #10
0
        public static void makeACBrackets()
        {
            double width = Inches.One * 6.5;
            double height = Inches.One;
            double depth = Inches.One;
            double thickness = Inches.Quarter;

            var mainBox = new Cube(width, depth, height, true);
            var cutout = mainBox.Clone().Scale(1.1, 1, 1).Translate(0, thickness, thickness);
            var hole = new Cylinder(Inches.Eigth, Inches.One * 2, true) { Resolution = 30 }.Rotate(90, 0, 0);


            var whole = mainBox - cutout - hole.Translate(0, 0, Inches.Quarter) - 
                hole.Clone().Translate(-Inches.One * 2, 0, Inches.Quarter) - hole.Clone().Translate(+Inches.One * 2, 0, Inches.Quarter);
            whole.ToFile("acBracket");
        }
Exemple #11
0
        public static void makeDiceHolder()
        {
            double chamberDiameter = Inches.One;

            var singleChamberCenter = new Cylinder(chamberDiameter, Inches.Half + Inches.Eigth, true) { Resolution = 6 };
            var singleChamber = new Cylinder(chamberDiameter + Inches.Eigth, Inches.Half + Inches.Eigth, true) { Resolution = 6 } - singleChamberCenter.Scale(1, 1, 2);
            singleChamber = singleChamber.Rotate(0, 0, 30);
            var bottom = singleChamber;

            for (int angle = 60; angle < 420; angle+=60)
            {
                bottom += singleChamber.Clone().Translate(chamberDiameter - Inches.Sixteenth, 0, 0).Rotate(0, 0, angle);
            }

            var hexSection = bottom.Clone();
            var outerCylCenter = new Cylinder(chamberDiameter * 2.9, Inches.Half, true) { Resolution = 90 }.Translate(0, 0, Inches.Eigth);
            var outerCyl = (new Cylinder(chamberDiameter * 2.9 + Inches.Eigth, Inches.Half, true) { Resolution = 90 } - outerCylCenter).Translate(0, 0, bottom.Bounds().ZMin + Inches.Half);

            bottom += outerCyl;

            var lidCenter = new Cylinder(chamberDiameter * 2.9 + Inches.Eigth + Inches.Sixteenth*.5, Inches.One, true) { Resolution = 90 }.Translate(0, 0, Inches.Eigth);
            var lid = (new Cylinder(chamberDiameter * 2.9 + Inches.Quarter + Inches.Sixteenth * .5, Inches.One, true) { Resolution = 90 } - lidCenter).Translate(0, 0, bottom.Bounds().ZMin + Inches.Half);            

            var top = lid.Clone().Mirror(0, 0, 1).Rotate(0, 180, 0);
            //OSCADObject dragon = ImportedImage.FromFile("dragonInsignia.png", new ImageImportOptions() {
            //    UseGrayScale = true,
            //    HeightMapping = ImageImportOptions.HeightMappingMode.None,
            //    SimplificationAmount = 100
            //});
            //var topBounds = top.Bounds();

            //dragon = dragon.Scale(.1, .1, Inches.Quarter).Translate(-topBounds.Length/2 + Inches.Sixteenth,  -topBounds.Width/2 + Inches.Sixteenth, topBounds.ZMin - Inches.Eigth);

            var whole = top;//bottom;// /*bottom + */ top - dragon;
            whole.ToFile("diceHolder_cap").Open();
        }
Exemple #12
0
        public static void makepaddleHandle()
        {
            double holeSize = Inches.One + Inches.Eigth;
            double holeHeight = Inches.One;
            double shaftSize = holeSize + Inches.Quarter;
            double totalLength = Inches.One * 8;
            double totalWidth = Inches.One * 5;

            var blade = new Sphere() { Resolution = 80 }.Resize(totalLength, totalWidth, Inches.One * 2);
            var copy = blade.Clone().Translate(0, 0, -Inches.One).Scale(1.4, 1.4, 1.1);
            blade = blade - copy;

            //var gap = new Cube(Inches.One, Inches.One * 8, Inches.One*8, true).Translate(blade.Bounds().XMin, 0, 0);
            //blade = blade - gap;

            OSCADObject shaft = new Cylinder(shaftSize, totalLength / 4, true) { Resolution = 80 }.Rotate(0, 90, 0);
            var hole = new Cylinder(holeSize, holeHeight * 2, true) { Resolution = 80 }.Rotate(0, 90, 0).Translate(shaft.Bounds().XMin, 0, 0);
            blade = blade - hole.Translate(blade.Bounds().XMin + Inches.Half, 0, +Inches.Quarter);
            shaft = shaft - hole;
            shaft = shaft.Translate(blade.Bounds().XMin + Inches.Half, 0, +Inches.Quarter);

            var top = new Cylinder(shaftSize, Inches.One * 3, true) { Resolution = 80 }.Rotate(90, 0, 0).Translate(shaft.Bounds().XMax, 0, shaft.Bounds().ZMax - shaftSize/2);
            var gapCloserLeft = new Sphere(shaftSize) { Resolution = 80 }.Translate(top.Bounds().XMax - shaftSize/2, top.Bounds().YMax, +Inches.Quarter);
            var gapCloserRight = gapCloserLeft.Mirror(0, 1, 0);

            var whole = shaft + top + gapCloserLeft + gapCloserRight;
            whole.ToFile("paddleHandle").Open();
        }
Exemple #13
0
        public static void  makeGreatSword()
        {
            double referenceWidth = Inches.Eigth;
            double overallLength = Inches.One*1.5;

            var tang = new Cylinder(referenceWidth, overallLength, true) { Resolution = 6 }.Scale(.5, 2, 1);
            var pommel = new Sphere(referenceWidth * 1.2){ Resolution = 11 }.Translate(0, 0, -Inches.Half - Inches.Eigth).Color("Gold");
            var hilt = new Cylinder(referenceWidth, Inches.Half * .75, true) { Resolution = 10 }
                .Rotate(90, 0, 0)
                .Translate(0, 0, -Inches.Quarter).Color("Gold");
            var hiltRight = new Sphere(referenceWidth * 1.1) { Resolution = 8 }
            .Scale(1, 1, 1.2).Color("Gold")
                .Translate(0, hilt.Bounds().YMin, hilt.Position().Z);
            var hiltLeft = hiltRight.Clone().Mirror(0, 1, 0);
            var hiltCenter = new Cylinder(referenceWidth * .9, Inches.Half * .8, true) { Resolution = 8 }
                .Translate(0, 0, -Inches.Quarter - Inches.Quarter*.75).Color("Gold");
            hilt = hilt + hiltLeft + hiltRight + hiltCenter;

            var blade = tang.Translate(0, 0, Inches.Half);
            var tip = new Cylinder(referenceWidth, Inches.Quarter, true) { Resolution = 6, Diameter2 = .1 }.Scale(.5, 2, 1).Translate(0, 0, blade.Bounds().ZMax + Inches.Eigth);
            blade = blade + tip;
            blade = blade.Color("Silver");

            var whole = (blade + pommel + hilt).Scale(.5, .5, .5);
            whole.ToFile("greatsword").Open();
        }
Exemple #14
0
        public static void makeDisk()
        {
            double glassGap = Inches.Eigth;
            double outer = (Inches.One * 3) + glassGap*2;
            double holeSize = (Inches.One - Inches.Sixteenth);
            double thickness = Inches.Quarter;

            var outerCylinder = new Cylinder(outer, thickness, true) { Resolution = 100 };
            var innerCutout = new Cylinder(outer - glassGap, thickness, true) { Resolution = 100 }.Translate(0, 0, thickness - Inches.Sixteenth);

            var hole = new Cylinder(holeSize, thickness * 2, true) { Resolution = 100 };

            var whole = (outerCylinder - innerCutout) - hole;
            whole.ToFile("candleDisk").Open();
        }
Exemple #15
0
        public void Cylinder_UncenteredPositionZValueIsHalfTheHeight()
        {
            var cylinder = new Cylinder(3, 40);

            Assert.AreEqual(new Vector3(0, 0, 20), cylinder.Position());
        }
Exemple #16
0
        public static void makeLoop()
        {
            double outerDiam = Inches.Quarter+ Inches.Sixteenth;
            double height = Inches.Eigth + Inches.Sixteenth;
            double holeSize = Inches.Quarter;
            double paddingSize = Inches.Sixteenth;


            var outer = new Cylinder(holeSize + paddingSize, height, true) { Resolution = 50 };
            var inner = new Cylinder(holeSize, height*2, true) { Resolution = 50 };            

            var bounds = outer.Bounds();
            var bottomDisk = new Cylinder(outerDiam + Inches.Eigth, Inches.Sixteenth / 2, true) { Resolution = 50 }.Translate(0, 0, bounds.ZMin - Inches.Sixteenth / 4);
        

            var whole = ((outer + bottomDisk) - inner);

            whole.ToFile("loop");

            var topDisk = new Cylinder(outerDiam + Inches.Eigth, Inches.Sixteenth / 2, true) - new Cylinder(holeSize + Inches.Sixteenth, Inches.Half, true) { Resolution = 50 };
            topDisk.ToFile("topLoop");
        }
Exemple #17
0
 public void Minkowski_BoundsThrowsNotSupportedException()
 {
     var obj = new Cylinder().Minkowski(new Sphere()).Translate(0, 5, 5);
     obj.Bounds();
 }
Exemple #18
0
        public void Minkowski_PositionThrowsNotSupportedException()
        {
            var obj = new Cylinder().Minkowski(new Sphere()).Translate(0, 5, 5);

            var pos = obj.Position();
        }