compas icon indicating copy to clipboard operation
compas copied to clipboard

method for sorting points by z (or x, or y) values

Open nizartaha opened this issue 4 years ago • 3 comments

Feature Request

A nice little feature to have is to be able sort points by their z (or x, or y) coordinates.

Details

i needed it to know the upper corners of a bounding box in compas.datastructures.mesh_bounding_box

nizartaha avatar Jun 25 '20 15:06 nizartaha

the bounding box is (or should be) a "structured" object. does the following not work for you?

box = mesh.bounding_box()

bottom = box[:4]
top = box[4:]

bottom_diagonal = bottom[0], bottom[2]
top_diagonal = top[0], top[2]

box_diagonal = bottom[0], top[2]

tomvanmele avatar Jun 25 '20 18:06 tomvanmele

It does work . Thank you Tom Its beneficial to note it in the Documentation i guess. I couldn't tell from reading there. The top and bottom points under Examples seem duplicated. https://compas-dev.github.io/main/api/generated/compas.datastructures.mesh_bounding_box.html#compas.datastructures.mesh_bounding_box

and maybe it is still beneficial to have a feature to sorting a collection of points by z or x or y. i dont have a specific case for it right now.

nizartaha avatar Jun 25 '20 19:06 nizartaha

yes indeed, this should be documented. the example is also not great i guess...

tomvanmele avatar Jun 25 '20 19:06 tomvanmele

@tomvanmele can you consider closing this?

jf--- avatar Apr 22 '24 21:04 jf---

yes, the bounding box functions now return a box...

tomvanmele avatar Apr 23 '24 07:04 tomvanmele