本文整理汇总了C++中FloatArray::distance方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatArray::distance方法的具体用法?C++ FloatArray::distance怎么用?C++ FloatArray::distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatArray
的用法示例。
在下文中一共展示了FloatArray::distance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lcoords
double
QTrPlaneStrain :: SpatialLocalizerI_giveDistanceFromParametricCenter(const FloatArray &coords)
{
FloatArray lcoords(3), gcoords;
double dist;
int size, gsize;
lcoords.at(1) = lcoords.at(2) = lcoords.at(3) = 1. / 3.;
this->computeGlobalCoordinates(gcoords, lcoords);
if ( ( size = coords.giveSize() ) < ( gsize = gcoords.giveSize() ) ) {
_error("SpatialLocalizerI_giveDistanceFromParametricCenter: coordinates size mismatch");
}
if ( size == gsize ) {
dist = coords.distance(gcoords);
} else {
FloatArray helpCoords = coords;
helpCoords.resize(gsize);
dist = helpCoords.distance(gcoords);
}
return dist;
}
示例2: lcoords
double
Tetrah1_ht :: SpatialLocalizerI_giveDistanceFromParametricCenter(const FloatArray &coords)
{
FloatArray lcoords(3), gcoords;
double dist;
int size, gsize;
lcoords.zero();
this->computeGlobalCoordinates(gcoords, lcoords);
if ( ( size = coords.giveSize() ) < ( gsize = gcoords.giveSize() ) ) {
OOFEM_ERROR("coordinates size mismatch");
}
if ( size == gsize ) {
dist = coords.distance(gcoords);
} else {
FloatArray helpCoords = coords;
helpCoords.resizeWithValues(gsize);
dist = helpCoords.distance(gcoords);
}
return dist;
}
示例3: checkIfCorner
void PrescribedGradientBCWeakPeriodic :: checkIfCorner(bool &oIsCorner, bool &oDuplicatable, const FloatArray &iPos, const double &iNodeDistTol) const
{
oIsCorner = false;
oDuplicatable = false;
FloatArray cornerPos = mLC;
if( iPos.distance(cornerPos) < iNodeDistTol ) {
oIsCorner = true;
}
cornerPos = {mUC[0], mLC[1]};
if( iPos.distance( cornerPos ) < iNodeDistTol ) {
oIsCorner = true;
}
cornerPos = {mUC[0], mUC[1]};
if( iPos.distance( cornerPos ) < iNodeDistTol ) {
oIsCorner = true;
if(mTractionInterpOrder == 1) {
oDuplicatable = true;
}
}
cornerPos = {mLC[0], mUC[1]};
if( iPos.distance( cornerPos ) < iNodeDistTol ) {
oIsCorner = true;
}
}
示例4: checkIfCorner
void PrescribedGradientBCWeakDirichlet :: checkIfCorner(bool &oIsCorner, bool &oDuplicatable, const FloatArray &iPos, const double &iNodeDistTol) const
{
oIsCorner = false;
oDuplicatable = false;
FloatArray cornerPos = mLC;
if ( iPos.distance(cornerPos) < iNodeDistTol ) {
oIsCorner = true;
oDuplicatable = true;
}
cornerPos = {
mUC [ 0 ], mLC [ 1 ]
};
if ( iPos.distance(cornerPos) < iNodeDistTol ) {
oIsCorner = true;
oDuplicatable = true;
}
cornerPos = {
mUC [ 0 ], mUC [ 1 ]
};
if ( iPos.distance(cornerPos) < iNodeDistTol ) {
oIsCorner = true;
oDuplicatable = true;
}
cornerPos = {
mLC [ 0 ], mUC [ 1 ]
};
if ( iPos.distance(cornerPos) < iNodeDistTol ) {
oIsCorner = true;
oDuplicatable = true;
}
}
示例5:
void
MMAContainingElementProjection :: __init(Domain *dold, IntArray &type, FloatArray &coords, Set &elemSet, TimeStep *tStep, bool iCohesiveZoneGP)
{
SpatialLocalizer *sl = dold->giveSpatialLocalizer();
FloatArray jGpCoords;
double distance, minDist = 1.e6;
Element *srcElem;
if ( ( srcElem = sl->giveElementContainingPoint(coords, elemSet) ) ) {
this->source = NULL;
for ( GaussPoint *jGp: *srcElem->giveDefaultIntegrationRulePtr() ) {
if ( srcElem->computeGlobalCoordinates( jGpCoords, jGp->giveNaturalCoordinates() ) ) {
distance = coords.distance(jGpCoords);
if ( distance < minDist ) {
minDist = distance;
this->source = jGp;
}
}
}
if ( !source ) {
OOFEM_ERROR("no suitable source found");
}
} else {
OOFEM_ERROR("No suitable element found");
}
}
示例6: calcPolarCoord
void EnrichmentItem :: calcPolarCoord(double &oR, double &oTheta, const FloatArray &iOrigin, const FloatArray &iPos, const FloatArray &iN, const FloatArray &iT, const EfInput &iEfInput, bool iFlipTangent)
{
FloatArray q = {
iPos.at(1) - iOrigin.at(1), iPos.at(2) - iOrigin.at(2)
};
const double tol = 1.0e-20;
// Compute polar coordinates
oR = iOrigin.distance(iPos);
if ( oR > tol ) {
q.times(1.0 / oR);
}
const double pi = M_PI;
// if( q.dotProduct(iT) > 0.0 ) {
// oTheta = asin( q.dotProduct(iN) );
// } else {
// if ( q.dotProduct(iN) > 0.0 ) {
// oTheta = pi - asin( q.dotProduct(iN) );
// } else {
// oTheta = -pi - asin( q.dotProduct(iN) );
// }
// }
const double tol_q = 1.0e-3;
double phi = iEfInput.mLevelSet;
if ( iFlipTangent ) {
phi *= -1.0;
}
double phi_r = 0.0;
if ( oR > tol ) {
phi_r = fabs(phi / oR);
}
if ( phi_r > 1.0 - XfemTolerances :: giveApproxZero() ) {
phi_r = 1.0 - XfemTolerances :: giveApproxZero();
}
if ( iEfInput.mArcPos < tol_q || iEfInput.mArcPos > ( 1.0 - tol_q ) ) {
double q_dot_n = q.dotProduct(iN);
if ( q_dot_n > 1.0 - XfemTolerances :: giveApproxZero() ) {
q_dot_n = 1.0 - XfemTolerances :: giveApproxZero();
}
oTheta = asin(q_dot_n);
} else {
if ( phi > 0.0 ) {
oTheta = pi - asin( fabs(phi_r) );
} else {
oTheta = -pi + asin( fabs(phi_r) );
}
}
}
示例7: FEIElementGeometryWrapper
double Tr21Stokes :: SpatialLocalizerI_giveDistanceFromParametricCenter(const FloatArray &coords)
{
FloatArray center;
FloatArray lcoords;
lcoords.setValues(3, 0.333333, 0.333333, 0.333333);
interpolation_quad.local2global(center, lcoords, FEIElementGeometryWrapper(this));
return center.distance(coords);
}
示例8: computeWeightFunction
double
TrabBoneNL3D :: computeWeightFunction(const FloatArray &src, const FloatArray &coord)
{
double dist = src.distance(coord);
if ( ( dist >= 0. ) && ( dist <= this->R ) ) {
double help = ( 1. - dist * dist / ( R * R ) );
return help * help;
}
return 0.0;
}
示例9: tr
bool Delaunay :: isInsideCC(const FloatArray &iP, const FloatArray &iP1, const FloatArray &iP2, const FloatArray &iP3) const
{
Triangle tr(iP1, iP2, iP3);
double r = tr.getRadiusOfCircumCircle();
FloatArray circumCenter;
tr.computeCenterOfCircumCircle(circumCenter);
double distance = circumCenter.distance(iP);
if ( distance < r ) {
return true;
} else {
return false;
}
}
示例10: computeWeightFunction
double
RCSDNLMaterial :: computeWeightFunction(const FloatArray &src, const FloatArray &coord)
{
// Bell shaped function decaying with the distance.
double dist = src.distance(coord);
if ( ( dist >= 0. ) && ( dist <= this->R ) ) {
double help = ( 1. - dist * dist / ( R * R ) );
return help * help;
}
return 0.0;
}
示例11: giveAllNodesWithinBox
void
DummySpatialLocalizer :: giveAllNodesWithinBox(nodeContainerType &nodeSet, const FloatArray &coords, const double radius)
{
int nnode;
nnode = this->giveDomain()->giveNumberOfDofManagers();
for ( int i = 1; i <= nnode; i++ ) {
DofManager *idofman = this->giveDomain()->giveDofManager(i);
Node *inode = dynamic_cast< Node * >(idofman);
if ( inode != NULL ) {
if ( coords.distance( inode->giveCoordinates() ) <= radius ) {
nodeSet.push_back(i);
}
}
}
}
示例12: intersects
bool Circle :: intersects(Element *element)
{
int count = 0;
for ( int i = 1; i <= element->giveNumberOfDofManagers(); i++ ) {
FloatArray *nodeCoor = element->giveDofManager(i)->giveCoordinates();
// distance from the node to the center of the circle
double dist = nodeCoor->distance(mVertices [ 0 ]);
if ( dist > this->radius ) {
count++;
}
}
if ( count == 0 || count == element->giveNumberOfDofManagers() ) {
return false;
} else {
return true;
}
}
示例13: giveAllElementsWithIpWithinBox
void
DummySpatialLocalizer :: giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius)
{
int nelem;
FloatArray jGpCoords;
nelem = this->giveDomain()->giveNumberOfElements();
for ( int i = 1; i <= nelem; i++ ) {
Element *ielem = this->giveDomain()->giveElement(i);
IntegrationRule *iRule = ielem->giveDefaultIntegrationRulePtr();
for ( GaussPoint *jGp: *iRule ) {
if ( ielem->computeGlobalCoordinates( jGpCoords, * ( jGp->giveCoordinates() ) ) ) {
double currDist = coords.distance(jGpCoords);
if ( currDist <= radius ) {
elemSet.insert(i);
}
}
}
} // end element loop
}
示例14: giveBoundingSphere
void PolygonLine :: giveBoundingSphere(FloatArray &oCenter, double &oRadius)
{
int nVert = giveNrVertices();
oCenter = {
0.0, 0.0
};
oRadius = 0.0;
if ( nVert > 0 ) {
for ( int i = 1; i <= nVert; i++ ) {
oCenter.add( giveVertex(i) );
}
oCenter.times( 1.0 / double( nVert ) );
for ( int i = 1; i <= nVert; i++ ) {
oRadius = std :: max( oRadius, oCenter.distance( giveVertex(i) ) );
}
}
}
示例15: computeWeightFunction
double
NonlocalMaterialExtensionInterface :: computeWeightFunction(const FloatArray &src, const FloatArray &coord)
{
return computeWeightFunction( src.distance(coord) );
}