2. Let B be an Object Bounding Box(OBB) given by a center point C; three orthogonal unit vectors u0, u1, and u2(V1,V2,V3) and three scalar values e0, e1, and e2 (x , y and z) specifying the box half widths along each axis A point P in world space relates to its corresponding point Q = (x, y, z) in the coordinate system of the OBB B as P = C + xu0 + yu1 + zu2.
3. Given P, the OBB-space coordinates can be solved for as follows. Only the derivation of the x coordinate is shown here. The other coordinates can be solved for in a similar manner.
4. P = C + xu0 + yu1 + zu2 ⇔ (original expression) P − C = xu0 + yu1 + zu2 ⇔ (moving C to left side) (P − C) · u0 = (xu0 + yu1 + zu2) · u0 ⇔ (taking dot product with u0 on both sides) (P − C) · u0 = x(u0 · u0) + y(u1 · u0) + z(u2 · u0) ⇔ (expanding dot product expression) (P − C) · u0 = x (simplifying using u0 · u0 = 1, u1 · u0 = u2 · u0 = 0)
5. The full set of OBB coordinates are thus given by x = (P −C) · u0, y = (P −C) · u1, and z = (P − C) · u2. To compute the point R on (or in) B closest to P, the same approach as used for an AABB can be applied by expressing P in the OBB coordinate system as Q, clamping Q to the extents e0, e1, and e2, and reexpressing Q in world coordinates.
6. Closest Point on Convex Polyhedron to Point Several approaches are available for locating the point on a convex polyhedron H closest to a point P in space. A simple-to-implement O(n) method is to compute the point on each polyhedron face closest to P and return the one closest to P. A concurrently run test determines if P lies inside all faces of H, in which case P is interior to H. To speed up the test, the face distance calculation would have to be run only when P lies in front of the face.
7. For larger polyhedra, a faster approach is to construct, as a precomputation, a hierarchy over the parts of the polyhedron. Utilizing a preconstructed hierarchy allows the closest point to be located in logarithmic time. An example of such a hierarchy is the Dobkin–Kirkpatrick hierarchy, described in Chapter 9. Chapter 9 also describes other approaches that can efficiently locate the closest point on the polyhedra (such as the GJK algorithm).
8. Sources: Real-time collision- detection by Christer Ericson Code edited in c++ Visual Studio http://pastie.org/1066466