void FrustumGrid::generateGridPlanes(Planes& xPlanes, Planes& yPlanes, Planes& zPlanes) { xPlanes.resize(dims.x + 1); yPlanes.resize(dims.y + 1); zPlanes.resize(dims.z + 1); float centerY = float(dims.y) * 0.5f; float centerX = float(dims.x) * 0.5f; for (int z = 0; z < (int) zPlanes.size(); z++) { ivec3 pos(0, 0, z); zPlanes[z] = glm::vec4(0.0f, 0.0f, 1.0f, -frustumGrid_clusterPosToEye(pos, vec3(0.0)).z); } for (int x = 0; x < (int) xPlanes.size(); x++) { auto slicePos = frustumGrid_clusterPosToEye(glm::vec3((float)x, centerY, 0.0)); auto sliceDir = glm::normalize(slicePos); xPlanes[x] = glm::vec4(sliceDir.z, 0.0, -sliceDir.x, 0.0); } for (int y = 0; y < (int) yPlanes.size(); y++) { auto slicePos = frustumGrid_clusterPosToEye(glm::vec3(centerX, (float)y, 0.0)); auto sliceDir = glm::normalize(slicePos); yPlanes[y] = glm::vec4(0.0, sliceDir.z, -sliceDir.y, 0.0); } }
void updatePlanesLookup() { delete [] self()._lookupPlanes; self()._lookupPlanes = new Plane *[planes.size()]; Plane **ptr = self()._lookupPlanes; for (Plane *p : planes) { *ptr++ = p; } }
void solve(Planes &CH) { // cout << CH.size() << endl; int m; // cin >> m; scanf("%d", &m); while (m--) { Point p; cin >> p.x >> p.y >> p.z; double ans = INF; for (int i = 0; i < CH.size(); ++ i) ans = min(ans, CH[i].dist2p(p)); // cout << ans << endl; printf("%.4lf\n", ans); } }