public void Polygon_RotateAndRoundTest_Orthogonal() { List<LineSegment> lineSegments = new List<LineSegment>(); lineSegments.Add(new LineSegment(Point.Origin, Point.MakePointWithInches(8, 0, 0))); lineSegments.Add(new LineSegment(Point.MakePointWithInches(8, 0, 0), Point.MakePointWithInches(8, 4, 0))); lineSegments.Add(new LineSegment(Point.MakePointWithInches(8, 4, 0), Point.MakePointWithInches(0, 4, 0))); lineSegments.Add(new LineSegment(Point.MakePointWithInches(0, 4, 0), Point.Origin)); Polygon testPolygon = new Polygon(lineSegments); Line rotationAxis = new Line(Point.MakePointWithInches(1, 0, 0)); //This is the X axis Angle rotationAngle = Angle.RightAngle; Polygon actualPolygon = testPolygon.Rotate(new Rotation(rotationAxis, rotationAngle)); List<LineSegment> expectedLineSegments = new List<LineSegment>(); expectedLineSegments.Add(new LineSegment(Point.Origin, Point.MakePointWithInches(8, 0, 0))); expectedLineSegments.Add(new LineSegment(Point.MakePointWithInches(8, 0, 0), Point.MakePointWithInches(8, 0, 4))); expectedLineSegments.Add(new LineSegment(Point.MakePointWithInches(8, 0, 4), Point.MakePointWithInches(0, 0, 4))); expectedLineSegments.Add(new LineSegment(Point.MakePointWithInches(0, 0, 4), Point.Origin)); Polygon expectedPolygon = new Polygon(expectedLineSegments); (actualPolygon == expectedPolygon).Should().BeTrue(); }
public void Polygon_RotateTest() { List<LineSegment> lineSegments = new List<LineSegment>(); lineSegments.Add(new LineSegment(Point.MakePointWithInches(0, 2, 3), Point.MakePointWithInches(-3, -2, 0))); lineSegments.Add(new LineSegment(Point.MakePointWithInches(-3, -2, 0), Point.MakePointWithInches(1, 1, -1))); lineSegments.Add(new LineSegment(Point.MakePointWithInches(1, 1, -1), Point.MakePointWithInches(0, 2, 3))); Polygon testPolygon = new Polygon(lineSegments); Line rotationAxis = new Line(new Direction(Point.MakePointWithInches(1, 1, 1), Point.MakePointWithInches(1, -1, -1))); Angle rotationAngle = new Angle(new Degree(), 212); Polygon actualPolygon = testPolygon.Rotate(new Rotation(rotationAxis, rotationAngle)); List<LineSegment> expectedLineSegments = new List<LineSegment>(); actualPolygon.Contains(new LineSegment(Point.MakePointWithInches(5.238195, 1.6816970, -1.919892), Point.MakePointWithInches(1.31623019, -1.08627088, -5.229959))); actualPolygon.Contains(new LineSegment(Point.MakePointWithInches(1.3162301, -1.0862708, -5.229959), Point.MakePointWithInches(2.843930, -1.46406412, -0.379865))); actualPolygon.Contains(new LineSegment(Point.MakePointWithInches(2.8439301, -1.4640641, -0.379865), Point.MakePointWithInches(5.238195, 1.681697053, -1.9198923))); }