public void Polyhedron_Shift_RotationOnly() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees toward z Angle xAngle = Angle.RightAngle; Rotation xRotation = new Rotation(Line.XAxis, xAngle); Polyhedron s = polyhedron.Shift(xRotation); s.LineSegments.Contains(new LineSegment(Point.Origin, Point.MakePointWithInches(4, 0, 0))).Should().BeTrue(); //no change s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, 0, 0), Point.MakePointWithInches(4, 0, 8))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, 0, 8), Point.MakePointWithInches(0, 0, 8))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, 0, 8), Point.Origin)).Should().BeTrue(); //from y axis to z axis s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, -3, 0), Point.MakePointWithInches(4, -3, 0))).Should().BeTrue(); //no change s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, -3, 0), Point.MakePointWithInches(4, -3, 8))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, -3, 8), Point.MakePointWithInches(0, -3, 8))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, -3, 8), Point.MakePointWithInches(0, -3, 0))).Should().BeTrue(); //from y axis to z axis s.LineSegments.Contains(new LineSegment(Point.Origin, Point.MakePointWithInches(0, -3, 0))).Should().BeTrue(); //no change s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, 0, 0), Point.MakePointWithInches(4, -3, 0))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, 0, 8), Point.MakePointWithInches(4, -3, 8))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, 0, 8), Point.MakePointWithInches(0, -3, 8))).Should().BeTrue(); //from y axis to z axis }
public void Polyhedron_ShiftXY() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees towards x Shift ninetyShift = new Shift(new Rotation(Line.ZAxis, -1 * Angle.RightAngle), Point.MakePointWithInches(8, 0)); Polyhedron result = polyhedron.Shift(ninetyShift); result.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(8, 0), Point.MakePointWithInches(16, 0))).Should().BeTrue(); result.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(8, 0), Point.MakePointWithInches(8, -4))).Should().BeTrue(); result.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(16, 0), Point.MakePointWithInches(16, -4))).Should().BeTrue(); result.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(8, -4), Point.MakePointWithInches(16, -4))).Should().BeTrue(); }
public void Polyhedron_ShiftYZ() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees towards z Shift nintyShift = new Shift(new Rotation(Line.XAxis, Angle.RightAngle)); Polyhedron result = polyhedron.Shift(nintyShift); result.LineSegments.Contains(new LineSegment(Point.Origin, Point.MakePointWithInches(0, 0, 8))).Should().BeTrue(); result.LineSegments.Contains(new LineSegment(Point.Origin, Point.MakePointWithInches(4, 0, 0))).Should().BeTrue(); result.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, 0, 0), Point.MakePointWithInches(4, 0, 8))).Should().BeTrue(); result.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(4, 0, 8), Point.MakePointWithInches(0, 0, 8))).Should().BeTrue(); }
public void Polyhedron_MultiShiftReturnToOriginal() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees towards z Angle zAngle = Angle.RightAngle; Rotation zRotation = new Rotation(Line.ZAxis, zAngle); Angle xAngle = Angle.RightAngle; //This is the X axis Rotation xRotation = new Rotation(Line.XAxis, xAngle); Shift ninetyShift = new Shift(new List<Rotation>() { zRotation, xRotation }); Polyhedron shifted = polyhedron.Shift(ninetyShift); //undo the previous shift Polyhedron s = new Polyhedron(shifted.Shift(ninetyShift.Inverse())); s.Should().Be(polyhedron); }
public void Polyhedron_Shift_TranslationOnly() { Polyhedron polyhedron = new TestRectangularBox2(); //Move 5 in. in z direction Point displacementPoint = Point.MakePointWithInches(0, 0, 5); Point displacementPoint2 = Point.MakePointWithInches(0, 3, 0); Polyhedron s1 = polyhedron.Shift(displacementPoint); Polyhedron s2 = s1.Shift(displacementPoint2); s2.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, 3, 5), Point.MakePointWithInches(0, 7, 5))); s2.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, 3, 5), Point.MakePointWithInches(8, 3, 5))); s2.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(8, 3, 5), Point.MakePointWithInches(8, 7, 5))); s2.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(8, 7, 5), Point.MakePointWithInches(0, 3, 9))); }
public void Polyhedron_Shift_RotateNotThroughOriginAndTranslate_ThenReturnToOriginal() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees toward z Angle xAngle = Angle.RightAngle; Line testAxis = new Line(Point.MakePointWithInches(1, 0, 0), Point.MakePointWithInches(1, 0, 1)); Rotation xRotation = new Rotation(testAxis, xAngle); Point displacementPoint = Point.MakePointWithInches(1, 3, -4); Shift ninetyShift = new Shift(xRotation, displacementPoint); Polyhedron s = new Polyhedron(polyhedron.Shift(ninetyShift)); Polyhedron s2 = s.Shift(ninetyShift.Inverse()); s2.Should().Be(polyhedron); }
public void Polyhedron_Shift_RotateNotThroughOriginAndTranslate() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees toward z Angle xAngle = new Angle(new Degree(), -90); Line testAxis = new Line(Point.MakePointWithInches(1, 0, 0), Point.MakePointWithInches(1, 0, 1)); Rotation xRotation = new Rotation(testAxis, xAngle); Point displacementPoint = Point.MakePointWithInches(-1, 2, 5); Shift ninetyShift = new Shift(xRotation, displacementPoint); Polyhedron s = new Polyhedron(polyhedron.Shift(ninetyShift)); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, 3, 5), Point.MakePointWithInches(8, 3, 5))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(8, 3, 5), Point.MakePointWithInches(8, -1, 5))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(8, -1, 5), Point.MakePointWithInches(0, -1, 5))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(0, -1, 5), Point.MakePointWithInches(0, 3, 5))).Should().BeTrue(); }
public void Polyhedron_Shift_RotateAndTranslate_ThenReturnToOriginal() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees toward z Angle xAngle = new Angle(new Degree(), 63); Rotation xRotation = new Rotation(Line.XAxis, xAngle); Point displacementPoint = Point.MakePointWithInches(0, 0, 1); Shift ninetyShift = new Shift(xRotation, displacementPoint); Polyhedron s = new Polyhedron(polyhedron.Shift(ninetyShift)); Polyhedron s2 = s.Shift(ninetyShift.Inverse()); s2.Should().Be(polyhedron); }
public void Polyhedron_Shift_RotateAndTranslate() { Polyhedron polyhedron = new TestRectangularBox2(); //rotate 90 degrees toward z Angle xAngle = Angle.RightAngle; Rotation xRotation = new Rotation(Line.XAxis, xAngle); Point displacementPoint = Point.MakePointWithInches(1, -2, 5); Shift ninetyShift = new Shift(xRotation, displacementPoint); Polyhedron s = new Polyhedron(polyhedron.Shift(ninetyShift)); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(1, -2, 5), Point.MakePointWithInches(5, -2, 5))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(5, -2, 5), Point.MakePointWithInches(5, -2, 13))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(5, -2, 13), Point.MakePointWithInches(1, -2, 13))).Should().BeTrue(); s.LineSegments.Contains(new LineSegment(Point.MakePointWithInches(1, -2, 13), Point.MakePointWithInches(1, -2, 5))).Should().BeTrue(); }