本文整理汇总了C++中AxisAlignedBox::Valid方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox::Valid方法的具体用法?C++ AxisAlignedBox::Valid怎么用?C++ AxisAlignedBox::Valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxisAlignedBox
的用法示例。
在下文中一共展示了AxisAlignedBox::Valid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Intersects
bool AxisAlignedBox::Intersects(const AxisAlignedBox& other) const {
if (!Valid() || !other.Valid()) {
throw std::invalid_argument("Can't check intersection with an invalid bounding box");
}
return !(max_.x() < other.min_.x() || min_.x() > other.max_.x() ||
max_.y() < other.min_.x() || min_.x() > other.max_.x() ||
max_.z() < other.min_.z() || min_.z() > other.max_.z());
}
示例2: Intersection
AxisAlignedBox AxisAlignedBox::Intersection(const AxisAlignedBox& other) const {
if (!Valid() || !other.Valid()) {
return AxisAlignedBox();
}
double x0;
double x1;
double y0;
double y1;
double z0;
double z1;
if (!Isect1d(min_.x(), max_.x(), other.min_.x(), other.max_.x(), &x0, &x1)) {
return AxisAlignedBox();
}
if (!Isect1d(min_.y(), max_.y(), other.min_.y(), other.max_.y(), &y0, &y1)) {
return AxisAlignedBox();
}
if (!Isect1d(min_.z(), max_.z(), other.min_.z(), other.max_.z(), &z0, &z1)) {
return AxisAlignedBox();
}
return AxisAlignedBox(QVector3D(x0, y0, z0), QVector3D(x1, y1, z1));
}