idTech4.idBounds.FromTransformedBounds C# (CSharp) Method

FromTransformedBounds() public static method

public static FromTransformedBounds ( idBounds bounds, Vector3 origin, Matrix axis ) : idBounds
bounds idBounds
origin Vector3
axis Matrix
return idBounds
		public static idBounds FromTransformedBounds(idBounds bounds, Vector3 origin, Matrix axis)
		{
			Vector3 center = (bounds.Min + bounds.Max) * 0.5f;
			Vector3 extents = bounds.Max - center;
			Vector3 rotatedExtents = Vector3.Zero;

			rotatedExtents.X = idMath.Abs(extents.X * axis.M11) + idMath.Abs(extents.Y * axis.M21) + idMath.Abs(extents.Y * axis.M31);
			rotatedExtents.Y = idMath.Abs(extents.X * axis.M12) + idMath.Abs(extents.Y * axis.M22) + idMath.Abs(extents.Y * axis.M32);
			rotatedExtents.Z = idMath.Abs(extents.X * axis.M13) + idMath.Abs(extents.Y * axis.M23) + idMath.Abs(extents.Y * axis.M33);

			center = origin; // TODO: + center * axis;

			idBounds result = new idBounds();
			result.Min = center - rotatedExtents;
			result.Max = center + rotatedExtents;

			return result;
		}