# calculate bounding sphere of an .obj 3d model?

This topic is 1508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i am just wondering how would i calculate the bounding sphere for an obj model, i have parsed vertices,index data to a vector etc, i need to use spheres around the models for view frusrum culling in increase rendering performance, thanks

##### Share on other sites

There are several approaches. Perhaps the best is an optimal sphere as discussed in that link. It's an involved algorithm that I'll let the article describe. But the idea is to calculate the smallest sphere that contains all the points.

A very simple approach is to calculate the average of all vertices, use that average position as the sphere center, calculate the distance from that center to each vertex and use the maximum distance found as the radius. EDIT: this approach can be relatively fast if you calculate distance-squared from the center to each vertex, and apply sqrt just once to calc the radius. The downside of this algorithm is: if there are many vertices grouped in one area, the center will be influenced by that, and the radius just has to grow to include the outlying points. If the mesh is fairly "regular," the result approaches optimal.

Another approach is to determine an axis aligned bounding box for the mesh vertices and calculate the sphere that contains that box. EDIT: this is fast, but is almost guaranteed to produce a larger sphere than other approaches.

There's no "best" answer as it depends on the shape of the mesh, whether the algorithm needs to be fast, etc.

Edited by Buckeye

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633703
• Total Posts
3013453
×