This helper function returns a vector that is made up of the largest components of the two specified vectors. Maximize is part of the suite of extra functionality that is available to C++ programmers who define D3D_OVERLOADS.
_D3DVECTOR Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2);
This function is defined as follows:
inline _D3DVECTOR
Maximize (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
{
return _D3DVECTOR( v1[0] > v2[0] ? v1[0] : v2[0],
v1[1] > v2[1] ? v1[1] : v2[1],
v1[2] > v2[2] ? v1[2] : v2[2]);
}
You could use the Maximize and Minimize functions to compute the bounding box for a set of points, in a function that looks like this:
void
ComputeBoundingBox(const D3DVECTOR *pts, int N, D3DVECTOR *min, D3DVECTOR *max)
{
int i;
*min = *max = pts[0];
for (i = 1; i < N; i += 1)
{
*min = Minimize(*min, pts[i]);
*max = Maximize(*max, pts[i]);
}
}