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 Rotation_Inverse()
 {
     Line axis = new Line(Point.MakePointWithInches(-2, 7, 0), Point.MakePointWithInches(0, 1, 1));
     Rotation rotation = new Rotation(axis, new Angle(new Degree(), 42));
     Point point = Point.MakePointWithInches(1, 1, 1);
     
     Point rotated = point.Rotate3D(rotation);
     Point unrotated = rotated.Rotate3D(rotation.Inverse());
    
     (point == unrotated).Should().BeTrue();
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a Shift with the given rotation and translation, or zero translation if it is omitted
 /// </summary>
 public Shift(Rotation rotation, Point displacement = null)
 {
     if (displacement == null)
     {
         this._matrix = rotation.Matrix;
     }
     else
     {
         this._matrix = new Translation(displacement).Matrix * rotation.Matrix;
     }
 }
        public void Rotation_Constructor_Matrix()
        {
            Vector vector1 = new Vector(Point.MakePointWithInches(2, 3, -6), Direction.Out, new Distance(1, Inches));
            Vector vector2 = new Vector(Point.MakePointWithInches(-5, 3, 7));

            //A very randomish axis
            Line testAxis = vector1.CrossProduct(vector2).Translate(Point.MakePointWithInches(3, -9, 10));

            Angle angle = new Angle(new Radian(), -173);

            Rotation rotation = new Rotation(testAxis, angle);
            Rotation fromMatrixConstructor = Rotation.RotationFromMatrix(rotation.Matrix);

            (fromMatrixConstructor.RotationAngle == angle.ProperAngle).Should().BeTrue();
            (fromMatrixConstructor.AxisOfRotation == testAxis).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 Rotation_EqualityTests()
        {
            Line axis1 = new Line(Point.MakePointWithInches(-2, 7, 0), Point.MakePointWithInches(0, 1, 1));
            Rotation rotation1 = new Rotation(axis1, new Angle(new Degree(), 42));

            Line axis2 = new Line(Point.MakePointWithInches(-2, 7, 0), Point.MakePointWithInches(0, 1, 1));
            Rotation rotation2 = new Rotation(axis2, new Angle(new Degree(), 42));

            Line axis3 = new Line(Point.MakePointWithInches(-3, 7, 0), Point.MakePointWithInches(0, 1, 1));
            Rotation rotation3 = new Rotation(axis3, new Angle(new Degree(), 42));

            Line axis4 = new Line(Point.MakePointWithInches(-3, 7, 0), Point.MakePointWithInches(0, 1, 1));
            Rotation rotation4 = new Rotation(axis4, new Angle(new Degree(), 63));

            (rotation1 == rotation2).Should().BeTrue();
            (rotation1 != rotation2).Should().BeFalse();
            (rotation1 == rotation3).Should().BeFalse();
            (rotation1 == rotation4).Should().BeFalse();
            (rotation3 != rotation4).Should().BeTrue();
        }
        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 Point_ShiftTest()
        {            
            Point point1 = Point.MakePointWithInches(1, 1, 0);

            Point displacementPoint = Point.MakePointWithInches(1, -1, 1);

            Angle angleAboutZAxis = Angle.RightAngle / 2;
            Rotation zRotation = new Rotation(Line.ZAxis, angleAboutZAxis);
            Angle angleAboutXAxis = new Angle(new Degree(), 112);
            Rotation xRotation = new Rotation(Line.XAxis, angleAboutXAxis);
            Shift testShift = new Shift(new List<Rotation>() { zRotation, xRotation }, displacementPoint);

            Point actual1 = point1.Shift(testShift);

            Point expected1 = Point.MakePointWithInches(1 + 0, -1 + -0.5298, 1 + 1.3112);

            actual1.Should().Be(expected1);
        }
 public static List<Point> Rotate(this IEnumerable<Point> pointList, Rotation rotation)
 {
     return pointList.Select(p => p.Rotate3D(rotation)).ToList();
 }
Esempio n. 10
0
 /// <summary>
 /// Perfomrs the given rotation on the Arc as an IEdge and returns a new object that has been rotated
 /// </summary>
 /// <param name="passedRotation">The Rotation to rotate this Arc with</param>
 /// <returns>A new Arc as an IEdge that has been rotated</returns>
 IEdge IEdge.Rotate(Rotation passedRotation)
 {
     return this.Rotate(passedRotation);
 }
Esempio n. 11
0
        /// <summary>
        /// Perfomrs the given rotation on the Arc a returns a new object that has been rotated
        /// </summary>
        /// <param name="passedRotation">The Rotation to rotate this Arc with</param>
        /// <returns>A new Arc that has been rotated</returns>
        public Arc Rotate(Rotation passedRotation)
        {
            Point newBasePoint = BasePoint.Rotate3D(passedRotation);
            Point newEndPoint = EndPoint.Rotate3D(passedRotation);

            //cheat a bit and make the direction into a line and then shift it
            Line directionLine = new Line(CenterPoint,NormalDirection).Rotate(passedRotation);

            return new Arc(newBasePoint, newEndPoint, directionLine.BasePoint, directionLine.Direction);
        }
 /// <summary>
 /// Rotates the list of polygons with the given rotation
 /// </summary>
 public static List<Polygon> Rotate(this IList<Polygon> passedPolygons, Rotation passedRotation)
 {
     return passedPolygons.Select(p => p.Rotate(passedRotation)).ToList();
 }
 /// <summary>
 /// Creates a copy of the given rotation
 /// </summary>
 public Rotation(Rotation toCopy)
 {
     this._rotationAngle = toCopy._rotationAngle;
     this._axisOfRotation = toCopy._axisOfRotation;
     this._matrix = new Matrix(toCopy._matrix);
 }
        public void Point_ShiftTest_RotateOnly()
        {
            Point point1 = Point.MakePointWithInches(1, 1, 0);

            Angle angleAboutZAxis = Angle.RightAngle / 2;
            Rotation zRotation = new Rotation(Line.ZAxis, angleAboutZAxis);
            Angle angleAboutXAxis = new Angle(new Degree(), 112);
            Rotation xRotation = new Rotation(Line.XAxis, angleAboutXAxis);
            Shift testShift = new Shift(new List<Rotation>() { zRotation, xRotation });

            Point actual1 = point1.Shift(testShift);

            Point expected1 = Point.MakePointWithInches(0, -0.52977372496316655, 1.3112359819417141);

            actual1.Should().Be(expected1);
        }
 /// <summary>
 /// Rotates the plane with the given rotation
 /// </summary>
 public new PlaneRegion Rotate(Rotation rotation)
 {
     return new PlaneRegion(this._Edges.Select(e => e.Rotate(rotation)).ToList());
 }
        ///// <summary>
        ///// 
        ///// </summary>
        ///// <param name="passedOrigin">The origin point of this coordinate system in reference to the world coordinate system</param>
        //public CoordinateSystem(Plane planeContainingTwoOfTheAxes, Vector axisInPassedPlaneToUseAsBase,
        //    Enums.Axis whichAxisIsPassed = Enums.Axis.X, Enums.AxisPlanes whichAxisPlaneIsPassed = Enums.AxisPlanes.XYPlane)
        //{

        //    //make sure the passed vector is in our plane
        //    if (!planeContainingTwoOfTheAxes.Contains(axisInPassedPlaneToUseAsBase))
        //    {
        //        throw new ArgumentOutOfRangeException("the passed axis was not in the plane");
        //    }

        //    Vector xAxis = new Vector(Point.Origin);
        //    Vector yAxis = new Vector(Point.Origin);
        //    Vector zAxis = new Vector(Point.Origin);

        //    //Vector normalAxis = new Vector(axisInPassedPlaneToUseAsBase.BasePoint, planeContainingTwoOfTheAxes.NormalVector.Direction, new Distance(new Inch(), 1));

        //    //Vector otherAxis;

        //    switch (whichAxisPlaneIsPassed)
        //    {
        //        case Enums.AxisPlanes.XYPlane:
        //            zAxis = new Vector(axisInPassedPlaneToUseAsBase.BasePoint, planeContainingTwoOfTheAxes.NormalVector.Direction, new Distance(new Inch(), 1));
        //            switch (whichAxisIsPassed)
        //            {
        //                //if its the x we were given the one we calculate is the y, so we want it 90 degrees (to the left)
        //                case Enums.Axis.X:
        //                    xAxis = axisInPassedPlaneToUseAsBase;
        //                    yAxis = zAxis.CrossProduct(xAxis);
        //                    //otherAxis = axisInPassedPlaneToUseAsBase.Rotate(new Rotation(planeContainingTwoOfTheAxes.NormalVector, Angle.RightAngle);
        //                    break;
        //                //if its the y we were the the y axis and we need to calculate the x which will be -90 degrees (to the right)
        //                case Enums.Axis.Y:
        //                    yAxis = axisInPassedPlaneToUseAsBase;
        //                    xAxis = yAxis.CrossProduct(zAxis);
        //                    //otherAxis = axisInPassedPlaneToUseAsBase.Rotate(new Rotation(planeContainingTwoOfTheAxes.NormalVector, -1 * Angle.RightAngle);
        //                    break;
        //                //the axis must be in the plane we were passed
        //                case Axis.Z:
        //                    throw new ArgumentOutOfRangeException("the passed axis type was not in the plane type");
        //            }
        //            break;
        //        case Enums.AxisPlanes.XZPlane:
        //            yAxis = new Vector(axisInPassedPlaneToUseAsBase.BasePoint, planeContainingTwoOfTheAxes.NormalVector.Direction, new Distance(new Inch(), 1));
        //            switch (whichAxisIsPassed)
        //            {
        //                //if its the x we were passed then we need to calculate z, which will be -90 degrees (to the right)
        //                case Enums.Axis.X:
        //                    xAxis = axisInPassedPlaneToUseAsBase;
        //                    zAxis = xAxis.CrossProduct(yAxis);
        //                    //otherAxis = axisInPassedPlaneToUseAsBase.Rotate(new Rotation(planeContainingTwoOfTheAxes.NormalVector, -1 * Angle.RightAngle);
        //                    break;
        //                //the axis must be in the plane we were passed
        //                case Enums.Axis.Y:
        //                    throw new ArgumentOutOfRangeException("the passed axis type was not in the plane type");
        //                //if its the z we were passed then we need to calculate x, which will be 90 degrees (to the left)
        //                case Axis.Z:
        //                    zAxis = axisInPassedPlaneToUseAsBase;
        //                    xAxis = yAxis.CrossProduct(zAxis);
        //                    //otherAxis = axisInPassedPlaneToUseAsBase.Rotate(new Rotation(planeContainingTwoOfTheAxes.NormalVector, Angle.RightAngle);
        //                    break;
        //            }
        //            break;
        //        case Enums.AxisPlanes.YZPlane:
        //            xAxis = new Vector(axisInPassedPlaneToUseAsBase.BasePoint, planeContainingTwoOfTheAxes.NormalVector.Direction, new Distance(new Inch(), 1));
        //            switch (whichAxisIsPassed)
        //            {
        //                //the axis must be in the plane we were passed
        //                case Enums.Axis.X:
        //                    throw new ArgumentOutOfRangeException("the passed axis type was not in the plane type");
        //                //if it is the Y axis then we need to find the z, which is 90 degrees (to the left)
        //                case Enums.Axis.Y:
        //                    yAxis = axisInPassedPlaneToUseAsBase;
        //                    zAxis = xAxis.CrossProduct(yAxis);
        //                    //otherAxis = axisInPassedPlaneToUseAsBase.Rotate(new Rotation(planeContainingTwoOfTheAxes.NormalVector, Angle.RightAngle);
        //                    break;
        //                //if it is the Z axis then we need to find the y, which is -90 degrees (to the right)
        //                case Axis.Z:
        //                    zAxis = axisInPassedPlaneToUseAsBase;
        //                    yAxis = zAxis.CrossProduct(xAxis);
        //                    //otherAxis = axisInPassedPlaneToUseAsBase.Rotate(new Rotation(planeContainingTwoOfTheAxes.NormalVector, -1 * Angle.RightAngle);
        //                    break;
        //            }
        //            break;
        //    }

        //    //we found our axes, now we can determine the angles from them
        //    //Since we rotate in the order Z, X, then Y, we must find the angles in the reverse order
        //    //i.e. y first, then x then z

        //    //if we find line up the z axis in the YZ plane with the y rotation, then we can rotate it around the x axis to make the z axes line up
        //    //and then we can z rotate to make the x and y coincide with the origins

        //    //first make them into unitvectors to simplify the calculations
        //    xAxis = xAxis.Direction*Inch;
        //    yAxis = yAxis.Direction*Inch;
        //    zAxis = zAxis.Direction*Inch;

        //    //now first find out the amount we need to rotate around the y axis to line up z in the yz plane

        //    //First project the z axis onto the xz plane
        //    Line projectedZAxis = ((Line)zAxis).ProjectOntoPlane(new Plane(Line.XAxis, Line.ZAxis));

        //    //then use the projected Line to find out how far we need to rotate in the Y direction to line up the z axes in the YZplane
        //    Angle angleBetweenCurrentZAndYZPlane = projectedZAxis.Direction.Theta;

        //    //if the projection is in the negative x direction we need to rotate negitively(clockwise) instead of positivly
        //    if (projectedZAxis.Direction.XComponent > 0)
        //    {
        //        angleBetweenCurrentZAndYZPlane = angleBetweenCurrentZAndYZPlane.Negate();
        //    }

        //    //http://www.vitutor.com/geometry/distance/line_plane.html
        //    //we can simplify the equation as this since it is unit vectors
        //    //sin(angle to plane) = z * planeNormal (which is the x axis by definition)
        //    //Distance dotProductOfZAndNormal = zAxis * Line.XAxis.UnitVector(new Inch());
        //    //Angle angleBetweenCurrentZAndYZPlane = new Angle(new Radian(), Math.Asin(dotProductOfZAndNormal.ValueInInches));

        //    //now rotate the axis (we only need to do z and x since we are done with y now)
        //    xAxis = xAxis.Rotate(new Rotation(Line.YAxis, angleBetweenCurrentZAndYZPlane));
        //    zAxis = zAxis.Rotate(new Rotation(Line.YAxis, angleBetweenCurrentZAndYZPlane));

        //    //now find out how much we need to rotate it in the x direction to line up z in the xz plane (meaning now z will be aligned with the world z)
        //    Angle angleBetweenZAndZAxis = zAxis.Direction.Theta;

        //    //now we need to rotate the x axis so we can line it up (the y and z we are done with)
        //    //if its negative we need to rotate it clockwise (negative) instead of ccw (positive)
        //    if (zAxis.Direction.YComponent < 0)
        //    {
        //        angleBetweenZAndZAxis = angleBetweenZAndZAxis.Negate();
        //    }

        //    //finally find out the z rotation needed to line up the x axis with the xz plane (this also forces the y to be lined up)
        //    xAxis = xAxis.Rotate(new Rotation(Line.XAxis, angleBetweenZAndZAxis));
        //    Angle angleBetweenXAndXAxis = xAxis.Direction.Phi;

        //    //now we know all our angles, but we have to take the negative of them because we were transforming back to
        //    //the origin and we store the tranform from the origin
        //    var _xAxisRotationAngle = angleBetweenZAndZAxis.Negate();
        //    var _yAxisRotationAngle = angleBetweenCurrentZAndYZPlane.Negate();
        //    var _zAxisRotationAngle = angleBetweenXAndXAxis.Negate();

        //    var rotationX = new Rotation(Line.XAxis, _xAxisRotationAngle);
        //    var rotationY = new Rotation(Line.YAxis, _yAxisRotationAngle);
        //    var rotationZ = new Rotation(Line.ZAxis, _zAxisRotationAngle);
        //    this.ShiftFromThisToWorld = new Shift(new List<Rotation>() { rotationX, rotationY, rotationZ }, axisInPassedPlaneToUseAsBase.BasePoint);
        //}

        /// <summary>
        /// Creates a new coordinate system with the given origin point and with the given rotations.
        /// The inputs are extrinsic angle, i.e. about the global axes
        /// </summary>
        /// <param name="passedTranslationToOrigin">The origin point of this coordinate system in reference to the world coordinate system</param>
        /// <param name="passedXAxisRotation">The rotation around the world coordinate system's X axis to rotate around to get to this
        /// coordinate system</param>
        /// <param name="passedYAxisRotation">The rotation around the world coordinate system's Y axis to rotate around to get to this
        /// coordinate system</param>
        /// <param name="passedZAxisRotation">The rotation around the world coordinate system's Z axis to rotate around to get to this
        /// coordinate system</param>
        public CoordinateSystem(Point translationToOrigin, Angle xAxisRotationAngle,
            Angle yAxisRotationAngle, Angle zAxisRotationAngle)
        {
            var rotationX = new Rotation(Line.XAxis, xAxisRotationAngle);
            var rotationY = new Rotation(Line.YAxis, yAxisRotationAngle);
            var rotationZ = new Rotation(Line.ZAxis, zAxisRotationAngle);
            this.ShiftFromThisToWorld = new Shift(new List<Rotation>() { rotationX, rotationY, rotationZ }, translationToOrigin);
        }
Esempio n. 17
0
        /// <summary>
        /// Returns a matrix that can be multiplied by another matrix to represent a rotation of that matrix about the passed axis line by the specified angle
        /// </summary>>
        public static Matrix RotationMatrixAboutOrigin(Rotation passedRotation)
        {
            Matrix rotationMatrix = new Matrix(3);

            Direction rotationUnitVector = passedRotation.AxisOfRotation.Direction;

            double unitX = rotationUnitVector.X; //Projection onto x-axis
            double unitY = rotationUnitVector.Y;
            double unitZ = rotationUnitVector.Z;
            double theta = passedRotation.RotationAngle.InRadians.Value;

            double sinTheta = Math.Sin(theta);
            double cosTheta = Math.Cos(theta);

            double row0column0 = Math.Cos(theta) + unitX*unitX*(1 - Math.Cos(theta));
            double row0column1 = unitX*unitY*(1 - Math.Cos(theta)) - unitZ*Math.Sin(theta);
            double row0column2 = unitX*unitZ*(1 - Math.Cos(theta)) + unitY*Math.Sin(theta);
            double row1column0 = unitY*unitX*(1 - Math.Cos(theta)) + unitZ*Math.Sin(theta);
            double row1column1 = Math.Cos(theta) + unitY*unitY*(1 - Math.Cos(theta));
            double row1column2 = unitY*unitZ*(1 - Math.Cos(theta)) - unitX*Math.Sin(theta);
            double row2column0 = unitZ*unitX*(1 - Math.Cos(theta)) - unitY*Math.Sin(theta);
            double row2column1 = unitZ*unitY*(1 - Math.Cos(theta)) + unitX*Math.Sin(theta);
            double row2column2 = Math.Cos(theta) + unitZ*unitZ*(1 - Math.Cos(theta));

            rotationMatrix.SetElement(0, 0, row0column0);
            rotationMatrix.SetElement(0, 1, row0column1);
            rotationMatrix.SetElement(0, 2, row0column2);
            rotationMatrix.SetElement(1, 0, row1column0);
            rotationMatrix.SetElement(1, 1, row1column1);
            rotationMatrix.SetElement(1, 2, row1column2);
            rotationMatrix.SetElement(2, 0, row2column0);
            rotationMatrix.SetElement(2, 1, row2column1);
            rotationMatrix.SetElement(2, 2, row2column2);

            return rotationMatrix;
        }
        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();
        }
        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);
        }
 /// <summary>
 /// Rotates the list of plane regions with the given rotation
 /// </summary>
 public static List<PlaneRegion> Rotate(this IList<PlaneRegion> planeRegions, Rotation rotation)
 {
     return planeRegions.Select(p => p.Rotate(rotation)).ToList();
 }
        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 LineSegment_Rotate_ShouldRotateAsVector()
        {
            LineSegment lineSegment1 = new LineSegment(Point.MakePointWithInches(1, 0, 0));
            Rotation rotation = new Rotation(new Angle(45, Angle.Degrees));

            LineSegment lineSegment2 = lineSegment1.Rotate(rotation);

            lineSegment2.Should().Be(new LineSegment(Point.Origin, new Direction(rotation.RotationAngle), new Distance(Distance.Inches, 1)));
        }
 public IEdge Rotate(Rotation rotation)
 {
     throw new NotImplementedException();
 }