// Get 'next' MinBoundingBox, i.e. box after prospective movement public override Box GetNextBox(float angle, Vector2 axis, Vector2 vector) { // Entry logging #if IS_LOGGING_METHODS Log.Write(String.Format("Entering method for {0}", this.Name)); #endif // Declare result Box result; // Check if there is rotational motion if (angle == 0) { // If not, simply translate the current box and stop result = this.MinBoundingBox; result.TranslateBy(vector); goto exit; } // Otherwise, we must rotate and translate each vertex. First, we // initialize x- and y-axis [min, max] intervals float xMin = float.PositiveInfinity; float xMax = float.NegativeInfinity; float yMin = float.PositiveInfinity; float yMax = float.NegativeInfinity; // Loop through vertices for (int i = 0; i < this.Vertices.Count; i++) { // Point to current vertex Vector2 vertex = this.Vertices[i]; // Rotate and translate vertex vertex = Vector2.Rotate(this.Vertices[i], angle, axis) + vector; // Update [min, max] intervals if (vertex.X < xMin) { xMin = vertex.X; } if (vertex.X > xMax) { xMax = vertex.X; } if (vertex.Y < yMin) { yMin = vertex.Y; } if (vertex.Y > yMax) { yMax = vertex.Y; } } // Create box result = new Box(xMin, yMin, xMax - xMin, yMax - yMin); // [*] Exit trap exit: // Exit logging #if IS_LOGGING_METHODS Log.Write(String.Format("Exiting method for {0}", this.Name)); #endif // Return result return(result); }