bool CircleConeIntersect(const Circle * c, const Cone * cone) { Circle circle(cone->GetVertex(), cone->GetHeight()); if (Intersect(c, &circle) == true) { if ((c->ContainsPoint(cone->GetVertex()) == true) || (cone->ContainsPoint(c->GetCenter()) == true)) { return true; } Vector3D direction(cone->GetVertex(), cone->GetVertex() + cone->GetDirection()); Vector3D centerDirection(cone->GetVertex(), c->GetCenter()); Float angle = direction.GetZeroAngleD(); Float angleDif = centerDirection.GetZeroAngleD() - angle; if (AbsVal(angleDif) < cone->GetAngle()) { return true; } Float angle1 = angle + cone->GetAngle(); Float angle2 = angle - cone->GetAngle(); Float height = cone->GetHeight(); Point3D vertex = cone->GetVertex(); LineSegment line1(vertex, Point3D(vertex.GetX() + (CosD(angle1) * height), vertex.GetY() + (SinD(angle1) * height), 0)); LineSegment line2(vertex, Point3D(vertex.GetX() + (CosD(angle2) * height), vertex.GetY() + (SinD(angle2) * height), 0)); return ((Intersect(c, &line1) == true) || (Intersect(c, &line2) == true)); } return false; }
static void pushOverlapsNode(overlapSet *os, GTFtree *t, GTFnode *n, uint32_t start, uint32_t end, int matchType, FILTER_ENTRY_FUNC ffunc) { int dir; if(!n) return; dir = centerDirection(start, end, n); if(dir&1) { pushOverlaps(os, t, n->starts, start, end, matchType, 1, ffunc); pushOverlapsNode(os, t, n->left, start, end, matchType, ffunc); } if(dir&2) { if(dir!=3) pushOverlaps(os, t, n->ends, start, end, matchType, 0, ffunc); pushOverlapsNode(os, t, n->right, start, end, matchType, ffunc); } }
static int32_t countOverlapsNode(GTFtree *t, GTFnode *n, uint32_t start, uint32_t end, int strand, int matchType, int strandType, int32_t max, FILTER_ENTRY_FUNC ffunc) { int32_t cnt = 0; int dir; if(!n) return cnt; dir = centerDirection(start, end, n); if(dir&1) { cnt += countOverlapsEntry(t, n->starts, start, end, strand, matchType, strandType, 1, max, ffunc); if(max && cnt >= max) return max; cnt += countOverlapsNode(t, n->left, start, end, strand, matchType, strandType, max, ffunc); if(max && cnt >= max) return max; } if(dir&2) { if(dir!=3) cnt += countOverlapsEntry(t, n->starts, start, end, strand, matchType, strandType, 0, max, ffunc); if(max && cnt >= max) return max; cnt += countOverlapsNode(t, n->right, start, end, strand, matchType, strandType, max, ffunc); if(max && cnt >= max) return max; } return cnt; }