本文整理汇总了C++中DPoint::norm方法的典型用法代码示例。如果您正苦于以下问题:C++ DPoint::norm方法的具体用法?C++ DPoint::norm怎么用?C++ DPoint::norm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DPoint
的用法示例。
在下文中一共展示了DPoint::norm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: force
DPoint SpringEmbedderGridVariant::ForceModelGronemann::computeDisplacement(int j, double boxLength) const
{
const double cEps = eps();
const double cIELEps = m_idealEdgeLength + cEps;
const NodeInfo &vj = m_vInfo[j];
int grid_x = vj.m_gridX;
int grid_y = vj.m_gridY;
// repulsive forces on node j: F_rep(d) = iel^2 / d
DPoint force(0,0);
for(int gi = -1; gi <= 1; gi++) {
for(int gj = -1; gj <= 1; gj++) {
for(int u : m_gridCell(grid_x+gi,grid_y+gj)) {
if(u == j) continue;
DPoint dist = vj.m_pos - m_vInfo[u].m_pos;
double d = dist.norm();
if(d < boxLength) {
dist /= d * d + cEps;
force += dist;
}
}
}
}
force *= m_idealEdgeLength * m_idealEdgeLength;
DPoint disp(force);
// attractive forces on j: F_attr(d) = c / deg(v) * ln(d/iel)
const double c = 0.5;
DPoint forceRepSub(0,0); // subtract rep. force on adjacent vertices
force = DPoint(0,0);
for(int l = vj.m_adjBegin; l != vj.m_adjStop; ++l) {
int u = m_adjLists[l];
DPoint dist = vj.m_pos - m_vInfo[u].m_pos;
double d = dist.norm();
force -= log((d+cEps) / cIELEps) * dist;
if(d < boxLength) {
double f = 1.0 / (d * d + cEps);
forceRepSub += f * dist;
}
}
force *= c * (vj.m_adjStop-vj.m_adjBegin);
forceRepSub *= m_idealEdgeLength * m_idealEdgeLength;
disp += force - forceRepSub;
return disp;
}
示例2: disp
DPoint SpringEmbedderGridVariant::ForceModelBase::
computeMixedForcesDisplacement(int j, int boxLength,
std::function<DPoint(double, const DPoint &)> attractiveChange,
std::function<double()> attractiveFinal) const
{
DPoint disp(computeRepulsiveForce(j, boxLength, 2));
const NodeInfo &vj = m_vInfo[j];
DPoint forceAttr(0, 0);
DPoint forceRep(0, 0); // subtract rep. force on adjacent vertices
for (int i = vj.m_adjBegin; i != vj.m_adjStop; ++i) {
int u = m_adjLists[i];
DPoint dist = vj.m_pos - m_vInfo[u].m_pos;
double d = dist.norm();
forceAttr -= attractiveChange(d, dist);
if (d < boxLength) {
double f = 1.0 / (d * d + eps());
forceRep += f * dist;
}
}
forceAttr *= attractiveFinal();
forceRep *= m_idealEdgeLength * m_idealEdgeLength;
disp += forceAttr - forceRep;
return disp;
}
示例3: force
DPoint SpringEmbedderGridVariant::ForceModelBase::
computeRepulsiveForce(int j, double boxLength, int idealExponent, int normExponent) const
{
const NodeInfo &vj = m_vInfo[j];
int grid_x = vj.m_gridX;
int grid_y = vj.m_gridY;
// repulsive forces on node j: F_rep(d) = iel^2 / d^normExponent
DPoint force(0, 0);
for (int gi = -1; gi <= 1; ++gi) {
for (int gj = -1; gj <= 1; ++gj) {
for (int u : m_gridCell(grid_x + gi, grid_y + gj)) {
if (u == j) {
continue;
}
DPoint dist = vj.m_pos - m_vInfo[u].m_pos;
double d = dist.norm();
if(d < boxLength) {
dist /= std::pow(d, normExponent+1) + eps();
force += dist;
}
}
}
}
force *= std::pow(m_idealEdgeLength, idealExponent);
return force;
}