MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / computeIntersection

Function computeIntersection

CesiumGeospatial/src/S2CellBoundingVolume.cpp:94–118  ·  view source on GitHub ↗

* Computes intersection of 3 planes. */

Source from the content-addressed store, hash-verified

92 * Computes intersection of 3 planes.
93 */
94glm::dvec3
95computeIntersection(const Plane& p0, const Plane& p1, const Plane& p2) {
96 const glm::dvec3& n0 = p0.getNormal();
97 const glm::dvec3& n1 = p1.getNormal();
98 const glm::dvec3& n2 = p2.getNormal();
99
100 glm::dmat3x3 matrix(
101 glm::dvec3(n0.x, n1.x, n2.x),
102 glm::dvec3(n0.y, n1.y, n2.y),
103 glm::dvec3(n0.z, n1.z, n2.z));
104
105 double determinant = glm::determinant(matrix);
106
107 glm::dvec3 x0 = n0 * -p0.getDistance();
108 glm::dvec3 x1 = n1 * -p1.getDistance();
109 glm::dvec3 x2 = n2 * -p2.getDistance();
110
111 glm::dvec3 f0 = glm::cross(n1, n2) * glm::dot(x0, n0);
112 glm::dvec3 f1 = glm::cross(n2, n0) * glm::dot(x1, n1);
113 glm::dvec3 f2 = glm::cross(n0, n1) * glm::dot(x2, n2);
114
115 glm::dvec3 s = f0 + f1 + f2;
116
117 return s / determinant;
118}
119
120std::array<glm::dvec3, 8>
121computeVertices(const std::array<Plane, 6>& boundingPlanes) {

Callers 1

computeVerticesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected