Is there a way to get the point / line / curve “setting” the extend of a bounding box in a specific direction?
I have a mesh and need to get the point with the biggest z-value. From the bounding box, I can of course get the z-value itself, but how do I now find the point / curve that is actually touching the BoundingBox?
I tried Mesh/Plane intersections, but don’t get any intersections, since it is just a “touching” contact.
Any way to get the actuall touching point?
EDIT: Should propably have mentioned this before, I am working in RhinoCommon.
Should propably have mentioned this before, I am working in RhinoCommon.
But I will have a look if I can split the mesh in its components there and sort ist. Seems lile a good approach.
EDIT: Ok, I am a bit blind it seems. Just saw Mesh.Vertices, of course i can just look in those points…
EDIT2:
Here is some code. Because BoundingBox.Min is a Point3d and Mesh.Vertices returns Point3f one has to do some janky comparisons… Dang floating points.
double min_dist = double.MaxValue;
int min_index = -1;
for (int i = 0; i < obj_mesh.Vertices.Count; i++)
{
Point3d dpt = new Point3d(obj_mesh.Vertices[i]);
if (Math.Abs(dpt.Z - glob_bbox.Max.Z) < min_dist)
{
min_dist = Math.Abs(dpt.Z - glob_bbox.Max.Z);
min_index = i;
}
}
Point3d point_on_surface = new Point3d(obj_mesh.Vertices[min_index]);