Variant CharacterCamera::_get(const String& p_name) const { if (p_name=="type") return get_camera_type(); else if (p_name=="orbit") return get_orbit(); else if (p_name=="height") return get_height(); else if (p_name=="inclination") return get_inclination(); else if (p_name=="max_orbit_x") return get_max_orbit_x(); else if (p_name=="min_orbit_x") return get_min_orbit_x(); else if (p_name=="max_distance") return get_max_distance(); else if (p_name=="min_distance") return get_min_distance(); else if (p_name=="distance") return get_distance(); else if (p_name=="clip") return has_clip(); else if (p_name=="autoturn") return has_autoturn(); else if (p_name=="autoturn_tolerance") return get_autoturn_tolerance(); else if (p_name=="autoturn_speed") return get_autoturn_speed(); return Variant(); }
/** * @brief Returns the value of a property of this movement. * * Accepted keys: * - speed * - angle * - max_distance * - ignore_obstacles * - smooth * - displayed_direction * * @param key key of the property to get * @return the corresponding value as a string */ const std::string StraightMovement::get_property(const std::string &key) { std::ostringstream oss; if (key == "speed") { oss << get_speed(); } else if (key == "angle") { oss << get_angle(); } else if (key == "max_distance") { oss << get_max_distance(); } else if (key == "ignore_obstacles") { oss << are_obstacles_ignored(); } else if (key == "smooth") { oss << is_smooth(); } else if (key == "displayed_direction") { oss << get_displayed_direction4(); } else { Debug::die(StringConcat() << "Unknown property of StraightMovement: '" << key << "'"); } return oss.str(); }
static void get_max_distance(node * root,int * max_dis,int * max_dep) { if(!root){ *max_dis = 0; *max_dep = -1; return; } node *l = root->l; node *r = root->r; int l_max_dep,r_max_dep,l_max_dis,r_max_dis; get_max_distance(l,&l_max_dis,&l_max_dep); get_max_distance(r,&r_max_dis,&r_max_dep); *max_dep = imax(l_max_dep+1,r_max_dep+1); *max_dis = imax(imax(l_max_dis,r_max_dis),l_max_dep+r_max_dep+2); }
int main() { int max_distance,max_depth; node t[9] = {0}; node test2[4] = { 0 }; node test3[9] = { 0 }; node test4[9] = { 0 }; zlink(t,0,1,2); zlink(t,1,3,4); zlink(t,2,5,6); zlink(t,3,7,-1); zlink(t,5,-1,8); get_max_distance(&t[0],&max_distance,&max_depth); printf("test case 1 : max_distance #%d max_depth #%d\n",max_distance,max_depth); zlink(test2, 0, 1, 2); zlink(test2, 1, 3, -1); get_max_distance(&test2[0],&max_distance,&max_depth); printf("test case 2 : max_distance #%d max_depth #%d\n",max_distance,max_depth); zlink(test3, 0, -1, 1); zlink(test3, 1, 2, 3); zlink(test3, 2, 4, -1); zlink(test3, 3, 5, 6); zlink(test3, 4, 7, -1); zlink(test3, 5, -1, 8); get_max_distance(&test3[0],&max_distance,&max_depth); printf("test case 3 : max_distance #%d max_depth #%d\n",max_distance,max_depth); zlink(test4, 0, 1, 2); zlink(test4, 1, 3, 4); zlink(test4, 3, 5, 6); zlink(test4, 5, 7, -1); zlink(test4, 6, -1, 8); get_max_distance(&test4[0],&max_distance,&max_depth); printf("test case 4 : max_distance #%d max_depth #%d\n",max_distance,max_depth); return 0; }
bool CMeleeChecker::should_stop_melee (const CEntityAlive *enemy) { return distance_to_enemy(enemy) > get_max_distance(); }
void find_correspondance(Mat *left_image, Mat *right_image, const Mat fund, vector<Point2f> *firstPts, vector<Point2f> *secondPts, int cornercount = 12) { Size imSize1 = (*left_image).size(); Size imSize2 = (*right_image).size(); pair<Point2f, Point2f> epipoles = get_epipole_SVD(fund); Point2f epipole_left = epipoles.first; Point2f epipole_right = epipoles.second; Size imSize = imSize1; Point2f imgCenter1 = Point2f(imSize1.width/2, imSize1.height/2); Point2f imgCenter2 = Point2f(imSize2.width/2, imSize2.height/2); int quarter = get_quarter(epipole_left, imgCenter1); int position = get_position(epipole_left, imSize); pair<double, double> min_max_angle = get_min_max_angle(position, epipole_left, imSize); double max_distance = get_max_distance(quarter, epipole_left, imSize); double dist_to_epipole; vector<Match> min_dist_area_matches; double delta = 2; double bandwidth = 10 pair<Strip, Strip> strips; Mat im1, im2; Point2f p1, p2; vector<Match> matches, res_matches; Point2f direction_point; Mat epipole_line; double anglemin = min(min_max_angle.first, min_max_angle.second); double anglemax = max(min_max_angle.first, min_max_angle.second); for(double a = anglemin; a < anglemax; a+= delta) { direction_point = rotatePoint(Point2f(100, 0) + epipole_left, a, epipole_left); epipole_line = (right)?get_epipole_line(fund.t(), direction_point): get_epipole_line(fund, direction_point); strips = cutstrips(left_image, right_image, epipole_left, epipole_right, epipole_line, direction_point, bandwidth); matches = get_correspondent_points( &strips.first.strip, &strips.second.strip, 4, (right)?strips.second.mask: strips.first.mask); for (int i = 0; i < matches.size(); i++) { p1 = rotatePoint( matches[i].first_pt - strips.first.shift, -strips.first.angle, epipole_left); p2 = rotatePoint( matches[i].second_pt - strips.second.shift, -strips.second.angle, epipole_right); res_matches.push_back( Match(p1, p2, matches[i].distance)); } } sort(res_matches.begin(), res_matches.end(), compare_matches_orig_dist); double shift, shift_dist; double shift_eps = 50, shift_koef = 1.2; double min_dist, max_dist; int i = 0, j = 1; Point2f dist_p = Point2f(minDistance, minDistance); while(!(j >= res_matches.size()) && !((*firstPts).size() > cornercount)) { p1 = res_matches[i].first_pt + dist_p; p2 = res_matches[j].first_pt; if ((p1.x > p2.x) && (p1.y > p2.y)) { j++; } else { (*firstPts).push_back( res_matches[i].first_pt); (*secondPts).push_back( res_matches[i].second_pt); i = j; j++; } } (*firstPts).push_back(res_matches[i].first_pt); (*secondPts).push_back(res_matches[i].second_pt); }
int CReadBlastApp::simple_overlaps() { int nabsent=0; int saved_m_verbosity_threshold = m_verbosity_threshold; // m_verbosity_threshold = 300; if(PrintDetails()) NcbiCerr << "simple_overlaps starts: " << NcbiEndl; TSimpleSeqs& seqs=m_simple_seqs; // now calculated in CopyGenestoforgotthename TSimpleSeqs::iterator first_user_in_range = seqs.begin(); TSimpleSeqs::iterator first_user_non_in_range = seqs.begin(); TSimpleSeqs::iterator first_ext_in_range = m_extRNAtable2.begin(); TSimpleSeqs::iterator first_ext_non_in_range = m_extRNAtable2.begin(); TSimpleSeqs::iterator seq = seqs.begin(); NON_CONST_ITERATE(TSimpleSeqs, ext_rna, m_extRNAtable2) { int from, to; from = ext_rna->exons[0].from; to = ext_rna->exons[ext_rna->exons.size()-1].to; ENa_strand strand = ext_rna->exons[0].strand; int range_scale = to - from; int max_distance = get_max_distance(range_scale); string type2 = ext_rna->name; string ext_rna_range = printed_range(ext_rna); if(PrintDetails()) NcbiCerr << "simple_overlaps[" << type2 << "[" << ext_rna_range << "]" << "]" << NcbiEndl; // find BEST overlap, not good enough here TSimpleSeqs best_seq; find_overlap(seq, ext_rna, seqs, best_seq); // this will slide seq along seqs bool absent = true; string diag_name = ext_rna->name; // for buffer int n_user_neighbors=0; int n_ext_neighbors = 0; string bufferstr=""; NON_CONST_ITERATE(TSimpleSeqs, seq2, best_seq) { int overlap=0; overlaps(ext_rna, seq2, overlap); strstream seq2_range_stream; string seq2_range = printed_range(seq2); if(PrintDetails()) NcbiCerr << "simple_overlaps" << "[" << type2 << "[" << ext_rna_range << "]" << "[" << seq2_range << "]" << "]" << ". " << "Overlap = " << overlap << NcbiEndl; if(PrintDetails()) NcbiCerr << "ext_rna->type = " << ext_rna->type << NcbiEndl; if(PrintDetails()) NcbiCerr << "seq2->type = " << seq2->type << NcbiEndl; if(PrintDetails()) NcbiCerr << "strand = " << int(strand) << NcbiEndl; if(PrintDetails()) NcbiCerr << "seq2->exons[0].strand = " << int(seq2->exons[0].strand) << NcbiEndl; absent = absent && (!overlap || ext_rna->type != seq2->type); // Absent bool bad_strand = (overlap>0 && ext_rna->type == seq2->type && strand != seq2->exons[0].strand); // BadStrand if(!bad_strand) continue; string diag_name2 = seq2->name; int from2, to2; from2 = seq2->exons[0].from; to2 = seq2->exons[seq2->exons.size()-1].to; bool undef_strand = seq2->exons[0].strand == eNa_strand_unknown; if(!bufferstr.size()) { if(PrintDetails()) { if(first_user_in_range==seqs.end()) { NcbiCerr << "simple_overlaps: first_user_in_range is already at the end" << NcbiEndl; } else { NcbiCerr << "simple_overlaps: first_user_in_range = " << printed_range(first_user_in_range) << NcbiEndl; } } ugly_simple_overlaps_call(n_user_neighbors, n_ext_neighbors, ext_rna, first_user_in_range, first_user_non_in_range, seqs, max_distance, first_ext_in_range, first_ext_non_in_range, bufferstr); } strstream misc_feat; string seq_range = printed_range(seq); EProblem trnaStrandProblem = undef_strand ? eTRNAUndefStrand : eTRNABadStrand; misc_feat << "RNA does not match strand for feature located at " << seq_range << NcbiEndl; misc_feat << '\0'; // this goes to the misc_feat, has to be original location, and name, corrected strand problemStr problem = {trnaStrandProblem, bufferstr, misc_feat.str(), "", "", from2, to2, strand}; m_diag[diag_name2].problems.push_back(problem); if(PrintDetails()) NcbiCerr << "simple_overlaps: adding problem:" << "\t" << diag_name << "\t" << "eTRNABadStrand" << "\t" << bufferstr << "\t" << NcbiEndl; // this goes to the log, has to be new problemStr problem2 = {trnaStrandProblem, bufferstr, "", "", "", from, to, strand}; m_diag[diag_name].problems.push_back(problem2); } // best_Seq iteration NON_CONST_ITERATE(TSimpleSeqs, seq2, best_seq)