[Algorithms] transforming a plane
Brought to you by:
vexxed72
From: Charles B. <cb...@cb...> - 2000-09-06 19:19:59
|
Is there a fast way to transform a plane? Right now I'm doing it by rotating the normal and tranforming a point on the plane, then re-generating the 4d-vector form of the plane. It seems there should be a way to do it with a single 4x4 matrix multiply in some funny coordinate space. On a related note, is there a fast way to transform an axis-aligned bounding box? With an AABB defined by a 'min' and a 'max', I'm doing this : // the min transformed : VECTOR3D vMinT; frXForm.XFormVector(vMinT,min); // the three edges transformed : VECTOR3D vx,vy,vz; vx = (max.x - min.x) * frXForm.Axis(X_AXIS); vy = (max.y - min.y) * frXForm.Axis(Y_AXIS); vz = (max.z - min.z) * frXForm.Axis(Z_AXIS); min.x = vMinT.x + min(vx.x,0) + min(vy.x,0) + min(vz.x,0); min.y = vMinT.y + min(vx.y,0) + min(vy.y,0) + min(vz.y,0); min.z = vMinT.z + min(vx.z,0) + min(vy.z,0) + min(vz.z,0); max.x = vMinT.x + max(vx.x,0) + max(vy.x,0) + max(vz.x,0); max.y = vMinT.y + max(vx.y,0) + max(vy.y,0) + max(vz.y,0); max.z = vMinT.z + max(vx.z,0) + max(vy.z,0) + max(vz.z,0); Basically, transform the low corner (the 'min'), and then transform the edges along x,y, and z. I can't think of anything better. -------------------------------------- Charles Bloom www.cbloom.com |