##### Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

# Get the bounding box of a jsr 184 mesh

Article
Created: ed_welch (03 Nov 2007)
Last edited: hamishwillee (30 Jul 2013)

Something I wrote a long time ago, but comes in quite handy. This function returns the bounding box on any mesh

`// Gets the bounder box of any mesh// returns an array for the min and max of each axis// extreme[0].min = x axis min value, // extreme[1].min = y axis min value, etc...public MinMax[] GetExtremes(Mesh mesh){	MinMax[] extreme = new MinMax[3];	VertexBuffer vertexBuffer = mesh.getVertexBuffer();	float[] scaleBias = new float[4];	VertexArray postionArray = vertexBuffer.getPositions(scaleBias); 	float[] out = new float[vertexBuffer.getVertexCount() * 4];	Transform trans = new Transform(); 	trans.postTranslate(scaleBias[1], scaleBias[2], scaleBias[3]);	trans.postScale(scaleBias[0], scaleBias[0], scaleBias[0]);	trans.transform(postionArray, out, true);	int n;	int axis;	for (axis = 0; axis < 3; axis++)	{		extreme[axis] = new MinMax();		extreme[axis].max = out[axis];		extreme[axis].min = out[axis];	}	for (n = 4; n < out.length / 4; n++)	{		for (axis = 0; axis < 3; axis++)		{			if (extreme[axis].max < out[n * 4 + axis])			{				extreme[axis].max = out[n * 4 + axis];			}			if (extreme[axis].min > out[n * 4 + axis])			{				extreme[axis].min = out[n * 4 + axis];			}		}	}	mesh.getScale(scaleBias); // reuse scaleBias	for (axis = 0; axis < 3; axis++)	{		extreme[axis].max *= scaleBias[axis];		extreme[axis].min *= scaleBias[axis];	}	return extreme;}  public class MinMax{    float min = 0f, max = 0f;    MinMax() {}}`