//-------------------------------------------------------------------------------------------------- /// Transforms the plane with the given homogeneous transformation \a matrix //-------------------------------------------------------------------------------------------------- void Plane::transform(const Mat4d& matrix) { Vec3d n = normal(); Vec3d point = pointInPlane(); n.transformVector(matrix); point.transformPoint(matrix); setFromPointAndNormal(point, n); }
//-------------------------------------------------------------------------------------------------- /// Transform the min and max coordinate with the given transformation matrix //-------------------------------------------------------------------------------------------------- void BoundingBox::transform(const Mat4d& matrix) { // Check if box is invalid, and don't transform if so if (!isValid()) return; BoundingBox newBox; newBox.reset(); Vec3d node; node.set(m_min.x(), m_min.y(), m_min.z()); node.transformPoint(matrix); newBox.add(node); node.set(m_max.x(), m_min.y(), m_min.z()); node.transformPoint(matrix); newBox.add(node); node.set(m_max.x(), m_max.y(), m_min.z()); node.transformPoint(matrix); newBox.add(node); node.set(m_min.x(), m_max.y(), m_min.z()); node.transformPoint(matrix); newBox.add(node); node.set(m_min.x(), m_min.y(), m_max.z()); node.transformPoint(matrix); newBox.add(node); node.set(m_max.x(), m_min.y(), m_max.z()); node.transformPoint(matrix); newBox.add(node); node.set(m_max.x(), m_max.y(), m_max.z()); node.transformPoint(matrix); newBox.add(node); node.set(m_min.x(), m_max.y(), m_max.z()); node.transformPoint(matrix); newBox.add(node); *this = newBox; }