public void Sphere_BoundsAreInExpectedPositionCentered() { var obj = new Sphere(30); Assert.AreEqual(new Vector3(15, 15, 15), obj.Bounds().TopRight); Assert.AreEqual(new Vector3(-15, -15, -15), obj.Bounds().BottomLeft); }
public void Difference_MinusOperatorCreatesDifferenceObject() { var obj = new Cube() - new Sphere(); var diff = new Sphere().Difference(new Cube()); Assert.IsTrue(obj.GetType() == diff.GetType()); }
public void Difference_BoundsYieldsBoundsOfFirstChild() { var sphere = new Sphere().Translate(.25, .25, 1); var diff = sphere.Difference(new Cube()); Assert.AreEqual(sphere.Bounds(), diff.Bounds()); }
public void Difference_PositionYieldsPositionOfFirstChild() { var sphere = new Sphere().Translate(.25, .25, 1); var diff = sphere.Difference(new Cube()); Assert.AreEqual(sphere.Position(), diff.Position()); }
public void Sphere_ParameterlessSphereHasMethodCallAndEndsWithSemicolon() { var basicSphere = new Sphere(); string script = basicSphere.ToString(); Assert.IsTrue(script.StartsWith("sphere(")); Assert.IsTrue(script.TrimEnd().EndsWith(");")); }
public void Difference_ChainingMinusOperationAddsToTheSameDifferenceObject() { var obj = new Cube() - new Sphere() - new Text3D("WOW!") - new Cylinder().Translate(1, 2, 5); var diff = new Sphere().Difference(new Cube()); var childrenThatAreDiffs = obj.Children().Where(child => child.GetType() == diff.GetType()).Count(); Assert.AreEqual(0, childrenThatAreDiffs); }
public void Union_ChainingAdditionAddsToTheSameUnion() { var obj = new Cube() + new Sphere() + new Text3D("WOW!") + new Cylinder().Translate(1, 2, 5); var union = new Sphere().Union(new Cube()); var unionChildrenCount = obj.Children().Where(child => child.GetType() == union.GetType()).Count(); Assert.AreEqual(0, unionChildrenCount); }
public void Hull_BasisObjectAppearsInHullChildren() { var cube = new Cube(); var sphere = new Sphere().Translate(0, 0, 2); var hull = cube.Hull(sphere); var children = hull.Children(); Assert.IsTrue(children.Contains(cube)); Assert.IsTrue(children.Contains(sphere)); }
public void OSCADObject_IdsAreSequentialAndDistinct() { var obj1 = new Sphere(); var obj2 = new Cube(); var obj3 = new Sphere(); Assert.IsTrue(obj1.Id < obj2.Id && obj2.Id < obj3.Id); Assert.IsTrue(obj1.Id + 1 == obj2.Id); Assert.IsTrue(obj2.Id + 1 == obj3.Id); }
public void Sphere_CloneYieldsSameScript() { var sphere = new Sphere() { Diameter = 10, MinimumAngle = 5, MinimumFragmentSize = 5, Resolution = 30 }; var clone = sphere.Clone(); Assert.IsTrue(sphere.IsSameAs(clone)); }
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"); }
public void Sphere_ScriptOutputDoesNotContainResolutionValuesIfNotSpecified() { var sphere = new Sphere(); string script = sphere.ToString(); Assert.IsTrue(!script.Contains("$fn")); Assert.IsTrue(!script.Contains("$fa")); Assert.IsTrue(!script.Contains("$fs")); }
public void Sphere_PositionIsAtZero() { var sphere = new Sphere(); Assert.AreEqual(new Vector3(), sphere.Position()); }
public void Intersection_BoundsThrowsNotSupportedException() { var obj = new Sphere().Intersection(new Text3D("Sup")); var pos = obj.Bounds(); }
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(); }
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(); }
public void Sphere_ScriptOutpuHasResolutionValuesIfSpecified() { var sphere = new Sphere() { Resolution = 40, MinimumAngle = 5, MinimumFragmentSize = 2 }; string script = sphere.ToString(); Assert.IsTrue(script.Contains("$fn")); Assert.IsTrue(script.Contains("$fa")); Assert.IsTrue(script.Contains("$fs")); }
public void Setup() { this.sphere = new Sphere(10); }
public void OSCADObject_ChildrenWithRecursiveFalseReturnsOnlyDirectChildren() { var firstLevel = new Sphere().Union(new Cube(), new Sphere(), new Cylinder()); firstLevel.Name = "Union"; var secondLevel = new Text3D() { Name = "Text" }.Difference(firstLevel); var children = secondLevel.Children(false).ToList(); Assert.AreEqual("Text", children[0].Name); Assert.AreEqual("Union", children[1].Name); }