本文整理汇总了C++中ConvexPolygon::ApproxCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ ConvexPolygon::ApproxCenter方法的具体用法?C++ ConvexPolygon::ApproxCenter怎么用?C++ ConvexPolygon::ApproxCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConvexPolygon
的用法示例。
在下文中一共展示了ConvexPolygon::ApproxCenter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: n
void S4r::Layer::GetMaterialAverage(
const ConvexPolygon &poly,
CTensor2 &eps, CTensor2 &mu,
const std::vector<Material*> &mat,
const Material *bkmat,
std::vector<double> &value // workspace
){
size_t nmat = description.pattern.Overlap(poly, value);
if(2 != nmat){
eps = value[0] * bkmat->eps.block(0,0,2,2);
for(size_t s = 0; s < description.pattern.NumShapes(); ++s){
eps += value[s+1] * mat[description.pattern.GetShape(s).tag]->eps.block(0,0,2,2);
}
mu = value[0] * bkmat->mu.block(0,0,2,2);
for(size_t s = 0; s < description.pattern.NumShapes(); ++s){
mu += value[s+1] * mat[description.pattern.GetShape(s).tag]->mu.block(0,0,2,2);
}
}else{
// perform fancy averaging
int ip1 = -1, ip2 = -1;
for(size_t i = 0; i <= description.pattern.NumShapes(); ++i){
if(value[i] > 0){
if(ip1 >= 0){ ip2 = i; break; }
else{ ip1 = i; }
}
}
// Assert that ip1 and ip2 >= 0
CTensor2 eps1, mu1;
CTensor2 eps2, mu2;
const double fill1 = value[ip1], fill2 = value[ip2];
if(0 == ip1){
eps1 = bkmat->eps.block(0,0,2,2);
mu1 = bkmat->mu.block(0,0,2,2);
}else{
int imat = description.pattern.GetShape(ip1-1).tag;
eps1 = mat[imat]->eps.block(0,0,2,2);
mu1 = mat[imat]->mu.block(0,0,2,2);
}
{
int imat = description.pattern.GetShape(ip2-1).tag;
eps2 = mat[imat]->eps.block(0,0,2,2);
mu2 = mat[imat]->mu.block(0,0,2,2);
}
Vec2 n(description.pattern.GetShape(ip2-1).Normal(poly.ApproxCenter()));
AnisotropicAverage(n, fill1, eps1, fill2, eps2, eps);
AnisotropicAverage(n, fill1, mu1, fill2, mu2, mu );
}
}