| 22 | GltfBoundingBox::GltfBoundingBox() = default; |
| 23 | |
| 24 | GltfBoundingBox::GltfBoundingBox(const std::vector<model::PlanarSurfaceGroup>& planarSurfaceGroups) { |
| 25 | |
| 26 | // Bounding Box |
| 27 | BoundingBox boundingBox; |
| 28 | boundingBox.addPoint(Point3d(0, 0, 0)); |
| 29 | boundingBox.addPoint(Point3d(1, 1, 1)); |
| 30 | for (const auto& group : planarSurfaceGroups) { |
| 31 | boundingBox.add(group.transformation() * group.boundingBox()); |
| 32 | } |
| 33 | |
| 34 | double lookAtX = 0; // (boundingBox.minX().get() + boundingBox.maxX().get()) / 2.0 |
| 35 | double lookAtY = 0; // (boundingBox.minY().get() + boundingBox.maxY().get()) / 2.0 |
| 36 | double lookAtZ = 0; // (boundingBox.minZ().get() + boundingBox.maxZ().get()) / 2.0 |
| 37 | double lookAtR = |
| 38 | sqrt(std::pow(boundingBox.maxX().get() / 2.0, 2) + std::pow(boundingBox.maxY().get() / 2.0, 2) + std::pow(boundingBox.maxZ().get() / 2.0, 2)); |
| 39 | lookAtR = std::max(lookAtR, sqrt(std::pow(boundingBox.minX().get() / 2.0, 2) + std::pow(boundingBox.maxY().get() / 2.0, 2) |
| 40 | + std::pow(boundingBox.maxZ().get() / 2.0, 2))); |
| 41 | lookAtR = std::max(lookAtR, sqrt(std::pow(boundingBox.maxX().get() / 2.0, 2) + std::pow(boundingBox.minY().get() / 2.0, 2) |
| 42 | + std::pow(boundingBox.maxZ().get() / 2.0, 2))); |
| 43 | lookAtR = std::max(lookAtR, sqrt(std::pow(boundingBox.maxX().get() / 2.0, 2) + std::pow(boundingBox.maxY().get() / 2.0, 2) |
| 44 | + std::pow(boundingBox.minZ().get() / 2.0, 2))); |
| 45 | lookAtR = std::max(lookAtR, sqrt(std::pow(boundingBox.minX().get() / 2.0, 2) + std::pow(boundingBox.minY().get() / 2.0, 2) |
| 46 | + std::pow(boundingBox.maxZ().get() / 2.0, 2))); |
| 47 | lookAtR = std::max(lookAtR, sqrt(std::pow(boundingBox.minX().get() / 2.0, 2) + std::pow(boundingBox.maxY().get() / 2.0, 2) |
| 48 | + std::pow(boundingBox.minZ().get() / 2.0, 2))); |
| 49 | lookAtR = std::max(lookAtR, sqrt(std::pow(boundingBox.maxX().get() / 2.0, 2) + std::pow(boundingBox.minY().get() / 2.0, 2) |
| 50 | + std::pow(boundingBox.minZ().get() / 2.0, 2))); |
| 51 | lookAtR = std::max(lookAtR, sqrt(std::pow(boundingBox.minX().get() / 2.0, 2) + std::pow(boundingBox.minY().get() / 2.0, 2) |
| 52 | + std::pow(boundingBox.minZ().get() / 2.0, 2))); |
| 53 | |
| 54 | m_lookAtR = lookAtR; |
| 55 | m_lookAtX = lookAtX; |
| 56 | m_lookAtY = lookAtY; |
| 57 | m_lookAtZ = lookAtZ; |
| 58 | m_maxX = boundingBox.maxX().get(); |
| 59 | m_maxY = boundingBox.maxY().get(); |
| 60 | m_maxZ = boundingBox.maxZ().get(); |
| 61 | m_minX = boundingBox.minX().get(); |
| 62 | m_minY = boundingBox.minY().get(); |
| 63 | m_minZ = boundingBox.minZ().get(); |
| 64 | } |
| 65 | |
| 66 | double GltfBoundingBox::lookAtR() const { |
| 67 | return m_lookAtR; |
nothing calls this directly
no test coverage detected