2DBounds in Float Function


Little function to return a bounding box for an object relative to a plane.

So if you have a plane rotated arbitrarily in the middle of nowhere and you want a Bounding box of an object relative to the plane… this’ll return the position and dimensions (in float relative of the reference plane)

fn get2DRelativeBounds obj refObj =
objpos = nodegetboundingbox obj refObj.transform
objmin = [objpos[1].x,objpos[2].y]
objmax = [objpos[2].x,objpos[1].y]
objbounds = nodegetboundingbox refobj refobj.transform
minposx = ((objmin.x-objbounds[1].x)/(abs(objbounds[1].x)+abs(objbounds[2].x)))
minposy = ((objmin.y-objbounds[1].y)/(abs(objbounds[1].y)+abs(objbounds[2].y)))
minposy = (minposy - 1)*(-1)
maxposx = ((objmax.x-objbounds[1].x)/(abs(objbounds[1].x)+abs(objbounds[2].x)))
maxposy = ((objmax.y-objbounds[1].y)/(abs(objbounds[1].y)+abs(objbounds[2].y)))
maxposy = (maxposy - 1)*(-1)
objwidth = maxposx-minposx
objheight = maxposy-minposy
struct Bounds2D (pos, width, height)
return Bounds2D [minposx,minposy] objwidth objheight


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.