THE BOUNDING BOX OF A TRANSFORMED CIRCLE

  Consider a circle with radius r in the xz-plane, centred at h / 2
  along the y-axis.  In homogeneous coordinates, the coordinates of
  the circle can be parametrised using an angle ϕ, 0 ≤ ϕ ≤ 2π.

    x = r ∙ cos(ϕ)
    y = h / 2
    z = r ∙ sin(ϕ)
    w = 1

  The cylinder is transformed by a matrix V with elements

        [ v11 v12 v13 v14 ]
    V = [ v21 v22 v23 v24 ]
        [ v31 v32 v33 v34 ]
        [ v41 v42 v43 v44 ]

  Let x', y', z', and w' be the parametrised coordinates of the circle
  after transformation by V, such that

    [ x']       [ x ]
    [ y'] = V ∙ [ y ]
    [ z']       [ z ]
    [ w']       [ w ]

  or explicitly

    x' = r ∙ (v11 ∙ cos(ϕ) + v13 ∙ sin(ϕ)) + v12 ∙ h / 2 + v14
    y' = r ∙ (v21 ∙ cos(ϕ) + v23 ∙ sin(ϕ)) + v22 ∙ h / 2 + v24
    z' = r ∙ (v31 ∙ cos(ϕ) + v33 ∙ sin(ϕ)) + v32 ∙ h / 2 + v34
    w' = r ∙ (v41 ∙ cos(ϕ) + v43 ∙ sin(ϕ)) + v42 ∙ h / 2 + v44

  To find the extrema along the x-axis, determine the derivatives of
  x' with respect to the parameter ϕ

    dx'/dϕ = r ∙ (v13 ∙ cos(ϕ) - v11 ∙ sin(ϕ))

  Equating dx'/dϕ = 0 yields ϕ = atan(v13 / v11).  Since tan() has a
  period of π, another extrema will be found at ϕ = atan(v13 / v11) +
  π--one solution corresponds to the maximum, the other to the
  minimum.  Since cos(ϕ + π) = -cos(ϕ) and sin(ϕ + π) = -sin(ϕ) the
  extrema will be at

    x' = v12 ∙ h / 2 + v14 + r ∙ (v11 ∙ cos(ϕ) + v13 ∙ sin(ϕ))
    x' = v12 ∙ h / 2 + v14 - r ∙ (v11 ∙ cos(ϕ) + v13 ∙ sin(ϕ))

  If V is such that w' = 1, e.g. if the bottom row of V is [ 0 0 0 1],
  x' as derived above will correspond to the actual Cartesian
  coordinate of the extrema.


THE BOUNDING BOX OF A TRANSFORMED SPHERE

  Consider a sphere with radius r centred on the origin, in
  homogeneous coordinates

    x = r ∙ sin(ϑ) ∙ cos(ϕ)
    y = r ∙ sin(ϑ) ∙ sin(ϕ)
    z = r ∙ cos(ϑ)
    w = 1

  where 0 ≤ ϕ ≤ 2π and 0 ≤ ϑ ≤ π parametrise the sphere in terms of an
  azimuthal coordinate ϕ, and a polar coordinate ϑ.  Like above, the
  sphere is transformed by a matrix V such that

    x' = r ∙ (v11 ∙ sin(ϑ) ∙ cos(ϕ)
            + v12 ∙ sin(ϑ) ∙ sin(ϕ) + v13 ∙ cos(ϑ)) + v14
    y' = r ∙ (v21 ∙ sin(ϑ) ∙ cos(ϕ)
            + v22 ∙ sin(ϑ) ∙ sin(ϕ) + v23 ∙ cos(ϑ)) + v24
    z' = r ∙ (v31 ∙ sin(ϑ) ∙ cos(ϕ)
            + v32 ∙ sin(ϑ) ∙ sin(ϕ) + v33 ∙ cos(ϑ)) + v34
    w' = r ∙ (v41 ∙ sin(ϑ) ∙ cos(ϕ)
            + v42 ∙ sin(ϑ) ∙ sin(ϕ) + v43 ∙ cos(ϑ)) + v44

  The partial derivatives of x' with respect to the parameters ϕ and
  ϑ are found to be

    ∂x'/∂ϕ = r ∙ (v12 ∙ sin(ϑ) ∙ cos(ϕ) - v11 ∙ sin(ϑ) ∙ sin(ϕ))
    ∂x'/∂ϑ = r ∙ (v11 ∙ cos(ϑ) ∙ cos(ϕ) + v12 ∙ cos(ϑ) ∙ sin(ϕ)
                - v13 ∙ sin(ϑ))

  Now equate ∂x'/∂ϕ = 0 and ∂x'/∂ϑ = 0.  Dividing the first equation
  by sin(ϑ) and the second equation by cos(ϑ), while making use of the
  identities tan(ϕ) = sin(ϕ) / cos(ϕ) and tan(ϑ) = sin(ϑ) / cos(ϑ)
  yields

    tan(ϕ) = v12 / v11
    tan(ϑ) = (v11 ∙ cos(ϕ) + v12 ∙ sin(ϕ)) / v13

  Note this step requires ϑ ≠ nπ / 2, for any integer n.  However, in
  the case that ϑ = nπ

    x' = ± r ∙ v13 + v14

  and in the case that ϑ = 3nπ / 2

    x' = ± r * (v11 * cos(ϕ) + v12 * sin(ϕ)) + v14

  which is optimised by ϕ = atan(v12 / v11) + nπ.  For all other
  values, the extrema along the x-axis will have

    ϕ = atan(v12 / v11) + nπ
    ϑ = atan((v11 * cos(p) + v12 * sin(p)) / v13) + nπ

  The extrema along the y- and z-axes are derived analogously.


THE BOUNDING BOX OF A TRANSFORMED CONE

  A cone is a convex volume defined by a point and a circle.  The
  bounding box of a transformed cone is the smallest box that contains
  the transformed coordinates of the point AND the extrema of the
  transformed circle.


THE BOUNDING BOX OF A TRANSFORMED CYLINDER

  A cylinder is a convex volume defined by two circles.  The bounding
  box of a transformed cylinder is the smallest box that contains the
  transformed coordinates of both circles.
