int main() { seg s[150]; polygon poly[50]; int n, m, i, j, k, kk; while(scanf("%d", &n) == 1) { for(i = 0; i < n; i++) scanf("%lf %lf %lf %lf", &s[i].s.x, &s[i].s.y, &s[i].e.x, &s[i].e.y); scanf("%d", &m); for(i = 0; i < m; i++) { scanf("%d", &poly[i].n); for(j = 0; j < poly[i].n; j++) scanf("%lf %lf", &poly[i].p[j].x, &poly[i].p[j].y); } for(i = 0; i < n; i++) { int flag = 0; for(j = 0; j < m; j++) { int l, r; l = inPolygon(s[i].s, poly[j]); r = inPolygon(s[i].e, poly[j]); if(l != r) //Partially on land flag = 1; if(l == 1 && r == 1) { flag = 2; for(k = 0, kk = poly[j].n-1; k < poly[j].n; kk = k++) { if(intersection(poly[j].p[k], poly[j].p[kk], s[i].s, s[i].e)) flag = 1; } } if(flag) break; l = 0, r = 0; for(k = 0, kk = poly[j].n-1; k < poly[j].n; kk = k++) { if(intersection(poly[j].p[k], poly[j].p[kk], s[i].s, s[i].e)) l = 1; } if(l) flag = 1; if(flag) break; } printf("Submarine %d is ", i+1); if(!flag) puts("still in water."); else if(flag == 1) puts("partially on land."); else puts("completely on land."); } break; } return 0; }
bool inPartitionedPolygon(vec2 point, vector<vector<Edge>>* partition, float minY, float maxY) { float increment = (maxY - minY) / (float)(partition->size() - 1); unsigned int index = clamp((point.y - minY) / increment, 0, partition->size()-1); return inPolygon(point, &partition->at(index)); }
ed::UUID GUIPlugin::getEntityFromClick(const cv::Point2i& p) const { for(ed::WorldModel::const_iterator it_entity = world_model_->begin(); it_entity != world_model_->end(); ++it_entity) { const ed::EntityConstPtr& e = *it_entity; if (!e->shape()) { const pcl::PointCloud<pcl::PointXYZ>& chull_points = e->convexHull().chull; if (!chull_points.empty()) { std::vector<cv::Point2i> image_chull(chull_points.size()); for(unsigned int i = 0; i < chull_points.size(); ++i) image_chull[i] = coordinateToPixel(chull_points[i]); if (inPolygon(image_chull, p)) return e->id(); } } } return ""; }