本文整理汇总了C++中SVector3::normSq方法的典型用法代码示例。如果您正苦于以下问题:C++ SVector3::normSq方法的具体用法?C++ SVector3::normSq怎么用?C++ SVector3::normSq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVector3
的用法示例。
在下文中一共展示了SVector3::normSq方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: taylorDistanceSq1D
double taylorDistanceSq1D(const GradientBasis *gb, const fullMatrix<double> &nodesXYZ,
const std::vector<SVector3> &tanCAD)
{
const int nV = nodesXYZ.size1();
fullMatrix<double> dxyzdX(nV, 3);
gb->getGradientsFromNodes(nodesXYZ, &dxyzdX, 0, 0);
// const double dx = nodesXYZ(1, 0) - nodesXYZ(0, 0), dy = nodesXYZ(1, 1) - nodesXYZ(0, 1),
// dz = nodesXYZ(1, 2) - nodesXYZ(0, 2), h = 0.5*sqrt(dx*dx+dy*dy+dz*dz)/double(nV-1);
double distSq = 0.;
for (int i=0; i<nV; i++) {
SVector3 tanMesh(dxyzdX(i, 0), dxyzdX(i, 1), dxyzdX(i, 2));
const double h = 0.25*tanMesh.normalize(); // Half of "local edge length"
SVector3 diff = (dot(tanCAD[i], tanMesh) > 0) ?
tanCAD[i] - tanMesh : tanCAD[i] + tanMesh;
distSq += h*h*diff.normSq();
}
return distSq;
}
示例2: taylorDistanceSq2D
double taylorDistanceSq2D(const GradientBasis *gb, const fullMatrix<double> &nodesXYZ,
const std::vector<SVector3> &normCAD)
{
const int nV = nodesXYZ.size1();
fullMatrix<double> dxyzdX(nV, 3), dxyzdY(nV, 3);
gb->getGradientsFromNodes(nodesXYZ, &dxyzdX, &dxyzdY, 0);
double distSq = 0.;
for (int i=0; i<nV; i++) {
const double nz = dxyzdX(i, 0) * dxyzdY(i, 1) - dxyzdX(i, 1) * dxyzdY(i, 0);
const double ny = -dxyzdX(i, 0) * dxyzdY(i, 2) + dxyzdX(i, 2) * dxyzdY(i, 0);
const double nx = dxyzdX(i, 1) * dxyzdY(i, 2) - dxyzdX(i, 2) * dxyzdY(i, 1);
SVector3 normMesh(nx, ny, nz);
const double h = 0.25*sqrt(normMesh.normalize()); // Half of sqrt of "local area", to be adjusted w.r.t. el. type?
SVector3 diff = (dot(normCAD[i], normMesh) > 0) ?
normCAD[i] - normMesh : normCAD[i] + normMesh;
distSq += h*h*diff.normSq();
}
return distSq;
}