本文整理汇总了C++中Site::isPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ Site::isPoint方法的具体用法?C++ Site::isPoint怎么用?C++ Site::isPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::isPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solve
//virtual void set_type(int t) {type=t;}
int solve( Site* s1, double k1,
Site* s2, double k2,
Site* s3, double k3, std::vector<Solution>& slns ) {
if (debug && !silent)
std::cout << "ALTSEPSolver.\n";
Site* lsite;
Site* psite;
Site* third_site;
double lsite_k, third_site_k;
if ( type == 0 ) {
lsite = s3;
lsite_k = k3;
psite = s1; // psite_k = k1; l3 / p1 form a separator
third_site = s2;
third_site_k = 1;
} else if ( type == 1 ) {
lsite = s3;
lsite_k = k3;
psite = s2; // psite_k = k2; l3 / p2 form a separator
third_site = s1;
third_site_k = 1;
} else {
std::cout << "ALTSEPSolver FATAL ERROR! type not known.\n";
exit(-1);
return 0;
}
// separator direction
Point sv = (k3 == - 1) ? Point(lsite->a(),lsite->b()) : Point(-lsite->a(),-lsite->b());
if (debug && !silent) {
std::cout << "ALTSEPSolver type="<< type <<"\n";
std::cout << " s1= " << s1->str2() << "(k=" << k1<< ")\n";
std::cout << " s2= " << s2->str2() << "(k=" << k2<< ")\n";
std::cout << " s3= " << s3->str2() << "(k=" << k3<< ")\n";
std::cout << " lsite_k=" << lsite_k << "\n";
std::cout << " sv= " << sv << "\n";
}
// now we should have this:
assert( lsite->isLine() && psite->isPoint() );
double tsln(0);
if ( third_site->isPoint() ) {
double dx = psite->x() - third_site->x();
double dy = psite->y() - third_site->y();
if ( fabs(2*( dx*sv.x+dy*sv.y )) > 0 ) {
tsln = -(dx*dx+dy*dy) / (2*( dx*sv.x+dy*sv.y )); // check for divide-by-zero?
} else {
//std::cout << " no solutions. (isPoint)\n";
return 0;
}
} else if (third_site->isLine()) {
if ( fabs(( sv.x*third_site->a() + sv.y*third_site->b() + third_site_k )) > 0 ) {
tsln = -(third_site->a()*psite->x()+third_site->b()*psite->y()+third_site->c()) /
( sv.x*third_site->a() + sv.y*third_site->b() + third_site_k );
} else {
//std::cout << " no solutions. (isLine)\n";
return 0;
}
} else {
assert(0);
exit(-1);
}
Point psln = Point(psite->x(), psite->y() ) + tsln * sv;
slns.push_back( Solution( psln, tsln, k3 ) );
return 1;
}