Is it possible to get the area of a mesh, for instance an imaginary containing rectangle?
Thanks.
Is it possible to get the area of a mesh, for instance an imaginary containing rectangle?
Thanks.
Not sure if you’re talking about computing volume or a bounding box/volume. Or do you want a 2D rectangle that contains the mesh?
Hi,
Is this for 2D or 3D?
For 3D something like this would give you a bounding box for a list of points, calculating the area (well, volume in 3D) is then just a matter of width * height * depth.
// --------------------------------------------
void calculateAABoundingBox( vector<ofVec3f>& _points )
{
ofVec3f min( 99999999999999999, 99999999999999999, 99999999999999999 );
ofVec3f max( -99999999999999999, -99999999999999999, -99999999999999999 );
for( unsigned int i = 0; i < _points.size(); i++ )
{
ofVec3f p = _points.at(i);
min.x = MIN( min.x, p.x );
min.y = MIN( min.y, p.y );
min.z = MIN( min.z, p.z );
max.x = MAX( max.x, p.x );
max.y = MAX( max.y, p.y );
max.z = MAX( max.z, p.z );
}
setSize( max - min );
setPosition( min.getInterpolated( max, 0.5f ) );
}
ignore me - understand it now!
No worries, should have posted the whole thing, here we go:
And one for Oriented Bounding Boxes, though it won’t calculate an oriented bounding box for you, just for checking if points are inside.
Cheers - got your original snippet plugged in and working great. Thanks again.