/// <summary> /// Rotates the Story Perimeter and Rooms in the horizontal plane around the supplied pivot point. /// </summary> /// <param name="pivot">Vector3 point around which the Room Perimeter will be rotated.</param> /// <param name="angle">Angle in degrees to rotate the Perimeter.</param> /// <returns> /// None. /// </returns> public void Rotate(Vector3 pivot, double angle) { if (Perimeter != null) { Perimeter = Perimeter.Rotate(pivot, angle); } foreach (var room in Corridors) { room.Rotate(pivot, angle); } foreach (var room in Exclusions) { room.Rotate(pivot, angle); } foreach (var room in Openings) { room.Rotate(pivot, angle); } foreach (var room in Rooms) { room.Rotate(pivot, angle); } foreach (var room in Services) { room.Rotate(pivot, angle); } }
/// <summary> /// Rotates all Rooms and the Perimeter in the horizontal plane around the supplied pivot point. /// </summary> /// <param name="pivot">Vector3 point around which the RoomRow will be rotated.</param> /// <param name="angle">Angle in degrees to rotate the Perimeter.</param> /// <returns> /// None. /// </returns> public void Rotate(Vector3 pivot, double angle) { foreach (Room room in Rooms) { room.Rotate(pivot, angle); } Perimeter = Perimeter.Rotate(pivot, angle); }
/// <summary> /// Rotates the Room Perimeter in the horizontal plane around the supplied pivot point. /// </summary> /// <param name="pivot">Vector3 point around which the Room Perimeter will be rotated.</param> /// <param name="angle">Angle in degrees to rotate the Perimeter.</param> /// <returns> /// True if the Perimeter is successfully rotated. /// </returns> public bool Rotate(Vector3 pivot, double angle) { if (Perimeter == null) { return(false); } Perimeter = Perimeter.Rotate(pivot, angle); return(true); }
/// <summary> /// Rotates the Tower Perimeter and Stories in the horizontal plane around the supplied pivot point. /// </summary> /// <param name="pivot">Vector3 point around which the Room Perimeter will be rotated.</param> /// <param name="angle">Angle in degrees to rotate the Perimeter.</param> /// <returns> /// None. /// </returns> public void Rotate(Vector3 pivot, double angle) { foreach (Story story in Stories) { story.Rotate(pivot, angle); } foreach (Room core in Cores) { core.Rotate(pivot, angle); } if (Perimeter != null) { Perimeter = Perimeter.Rotate(pivot, angle); } }
/// <summary> /// Moves all Rooms along a 3D vector calculated between the supplied Vector3 points. /// </summary> /// <param name="from">Vector3 base point of the move.</param> /// <param name="to">Vector3 target point of the move.</param> /// <returns> /// None. /// </returns> public void MoveFromTo(Vector3 from, Vector3 to) { foreach (Room room in Rooms) { room.MoveFromTo(from, to); } Perimeter = Perimeter.MoveFromTo(from, to); var ang = Perimeter.Segments().OrderByDescending(s => s.Length()).ToList().First(); Angle = Math.Atan2(ang.End.Y - ang.Start.Y, ang.End.X - ang.Start.X) * (180 / Math.PI); perimeterJig = Perimeter.Rotate(Vector3.Origin, Angle * -1); compass = perimeterJig.Compass(); insert.MoveFromTo(from, to); Row = new Line(compass.SW, compass.SE).Rotate(Vector3.Origin, Angle); }
/// <summary> /// Creates a grid network of corridors within the Story and returns a list of spatially sorted RoomRows ready for population. /// </summary> /// <param name="rowLength">Distance between cross corridors.</param> /// <param name="roomDepth">Desired depth of Rooms.</param> /// <param name="corridorWidth">Width of all corridors.</param> /// <returns>A List of RoomRow</returns> public List <RoomRow> PlanGrid(double rowLength, double rowDepth, double corridorWidth = 3.0, bool split = true) { Corridors.Clear(); Rooms.Clear(); rowLength = rowLength.NearEqual(0.0) ? 1.0 : Math.Abs(rowLength); rowDepth = rowLength.NearEqual(0.0) ? 1.0 : Math.Abs(rowDepth); corridorWidth = rowLength.NearEqual(0.0) ? 1.0 : Math.Abs(corridorWidth); var row = Perimeter.Segments().OrderByDescending(s => s.Length()).First(); var ang = Math.Atan2(row.End.Y - row.Start.Y, row.End.X - row.Start.X) * (180 / Math.PI); var perimeterJig = Perimeter.Rotate(Vector3.Origin, ang * -1); var grid = new Grid2d(perimeterJig); grid.U.DivideByFixedLength(rowLength, FixedDivisionMode.RemainderAtBothEnds); grid.V.DivideByFixedLength(rowDepth, FixedDivisionMode.RemainderAtBothEnds); var uLines = grid.GetCellSeparators(GridDirection.U).Skip(1).Reverse().Skip(1).Reverse(); var vLines = grid.GetCellSeparators(GridDirection.V).Skip(1).Reverse().Skip(1).Reverse(); var ctrLines = new List <Line>(); foreach (var curve in uLines) { ctrLines.Add((Line)curve); } foreach (var curve in vLines) { ctrLines.Add((Line)curve); } foreach (var line in ctrLines) { var corridor = line.Thicken(corridorWidth); if (perimeterJig.Compass().Box.Covers(corridor)) { AddCorridor(new Room(corridor.Rotate(Vector3.Origin, ang), Height)); } } foreach (var cell in grid.CellsFlat) { var polygon = (Polygon)cell.GetCellGeometry(); var compass = polygon.Compass(); if (split) { var north = Polygon.Rectangle(compass.W, compass.NE).Rotate(Vector3.Origin, ang); var south = Polygon.Rectangle(compass.SW, compass.E).Rotate(Vector3.Origin, ang); AddRoom(new Room(north, Height)); AddRoom(new Room(south, Height)); continue; } else if (Math.Abs(compass.SizeY - rowDepth) <= 0.0001) { AddRoom(new Room(polygon.Rotate(Vector3.Origin, ang), Height)); } } var roomRows = new List <RoomRow>(); foreach (var room in Rooms) { roomRows.Add(new RoomRow(room.Perimeter)); } Rooms.Clear(); return(roomRows); }