# sr #108330: bounding boxes / spheres of Mesh elements

 Submitter: gianluca de santis Submitted: Thu 27 Jun 2013 10:36:53 AM UTC Category: None Priority: 5 - Normal Severity: 3 - Normal Privacy: Public Assigned to: None Open/Closed: Open Operating System: None
* Mandatory Fields

Comment Type & Canned Response:

## Discussion

Thu 27 Jun 2013 01:45:43 PM UTC, comment #1:

Commit 8eda126 adds a general array minmax function, and a
bboxes() method for Coords, Geometry, Formex, Mesh.

From these you can also compute:

centers = bb.mean(axis=1)
diagonal_size = length(bb)

Benedict Verhegghe <bverheg>
Thu 27 Jun 2013 10:36:53 AM UTC, original submission:

It would be usefull for some operations to have a rough estimation of the space (ie. a BOX or a SPHERE) taken by each element of a mesh. While it is not trivial to find the smallest bounding sphere, it is easy and very fast to find the sphere around the bbox of each element. This is of course larger (but not much) than the smallest bounding sphere. Should we add the following or a similar method to mesh.py? Or it is already available somewhere? (in coords.py there is a method working for all coords)

def elemBoxes(self):
"""
Returns bounding box, center and radius of all elements of a mesh (working for any possible eltype).
Centers are defined as mod point on the diagonal of the boxes; radii are the semidiagonals of the boxes.
"""
f = self.coords[self.elems]
boxes=concatenate([ f.min(axis=1), f.max(axis=1)], axis=1).reshape(-1, 2, 3)
diag = boxes[:, 1]-boxes[:, 0]
ce = boxes[:, 0]+diag*0.5
r = length(diag)*0.5
return boxes, ce, r

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by bverheg (Posted a comment)
•

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

## History

No changes have been made to this item